Show More
@@ -0,0 +1,77 b'' | |||||
|
1 | ========================================================= | |||
|
2 | Test features and behaviors related to the archived phase | |||
|
3 | ========================================================= | |||
|
4 | ||||
|
5 | $ cat << EOF >> $HGRCPATH | |||
|
6 | > [format] | |||
|
7 | > internal-phase=yes | |||
|
8 | > [extensions] | |||
|
9 | > strip= | |||
|
10 | > [experimental] | |||
|
11 | > EOF | |||
|
12 | ||||
|
13 | $ hg init repo | |||
|
14 | $ cd repo | |||
|
15 | $ echo root > a | |||
|
16 | $ hg add a | |||
|
17 | $ hg ci -m 'root' | |||
|
18 | ||||
|
19 | Test that bundle can unarchive a changeset | |||
|
20 | ------------------------------------------ | |||
|
21 | ||||
|
22 | $ echo foo >> a | |||
|
23 | $ hg st | |||
|
24 | M a | |||
|
25 | $ hg ci -m 'unbundletesting' | |||
|
26 | $ hg log -G | |||
|
27 | @ changeset: 1:883aadbbf309 | |||
|
28 | | tag: tip | |||
|
29 | | user: test | |||
|
30 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
31 | | summary: unbundletesting | |||
|
32 | | | |||
|
33 | o changeset: 0:c1863a3840c6 | |||
|
34 | user: test | |||
|
35 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
36 | summary: root | |||
|
37 | ||||
|
38 | $ hg strip --soft --rev '.' | |||
|
39 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
40 | saved backup bundle to $TESTTMP/repo/.hg/strip-backup/883aadbbf309-efc55adc-backup.hg | |||
|
41 | $ hg log -G | |||
|
42 | @ changeset: 0:c1863a3840c6 | |||
|
43 | tag: tip | |||
|
44 | user: test | |||
|
45 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
46 | summary: root | |||
|
47 | ||||
|
48 | $ hg log -G --hidden | |||
|
49 | o changeset: 1:883aadbbf309 | |||
|
50 | | tag: tip | |||
|
51 | | user: test | |||
|
52 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
53 | | summary: unbundletesting | |||
|
54 | | | |||
|
55 | @ changeset: 0:c1863a3840c6 | |||
|
56 | user: test | |||
|
57 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
58 | summary: root | |||
|
59 | ||||
|
60 | $ hg unbundle .hg/strip-backup/883aadbbf309-efc55adc-backup.hg | |||
|
61 | adding changesets | |||
|
62 | adding manifests | |||
|
63 | adding file changes | |||
|
64 | added 0 changesets with 0 changes to 1 files | |||
|
65 | (run 'hg update' to get a working copy) | |||
|
66 | $ hg log -G | |||
|
67 | o changeset: 1:883aadbbf309 | |||
|
68 | | tag: tip | |||
|
69 | | user: test | |||
|
70 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
71 | | summary: unbundletesting | |||
|
72 | | | |||
|
73 | @ changeset: 0:c1863a3840c6 | |||
|
74 | user: test | |||
|
75 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
76 | summary: root | |||
|
77 |
@@ -76,7 +76,8 b' def _findupdatetarget(repo, nodes):' | |||||
76 |
|
76 | |||
77 | return unode |
|
77 | return unode | |
78 |
|
78 | |||
79 |
def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None |
|
79 | def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None, | |
|
80 | soft=False): | |||
80 | with repo.wlock(), repo.lock(): |
|
81 | with repo.wlock(), repo.lock(): | |
81 |
|
82 | |||
82 | if update: |
|
83 | if update: | |
@@ -85,7 +86,10 b' def strip(ui, repo, revs, update=True, b' | |||||
85 | hg.clean(repo, urev) |
|
86 | hg.clean(repo, urev) | |
86 | repo.dirstate.write(repo.currenttransaction()) |
|
87 | repo.dirstate.write(repo.currenttransaction()) | |
87 |
|
88 | |||
88 | repair.strip(ui, repo, revs, backup) |
|
89 | if soft: | |
|
90 | repair.softstrip(ui, repo, revs, backup) | |||
|
91 | else: | |||
|
92 | repair.strip(ui, repo, revs, backup) | |||
89 |
|
93 | |||
90 | repomarks = repo._bookmarks |
|
94 | repomarks = repo._bookmarks | |
91 | if bookmarks: |
|
95 | if bookmarks: | |
@@ -110,7 +114,10 b' def strip(ui, repo, revs, update=True, b' | |||||
110 | ('k', 'keep', None, _("do not modify working directory during " |
|
114 | ('k', 'keep', None, _("do not modify working directory during " | |
111 | "strip")), |
|
115 | "strip")), | |
112 | ('B', 'bookmark', [], _("remove revs only reachable from given" |
|
116 | ('B', 'bookmark', [], _("remove revs only reachable from given" | |
113 |
" bookmark"), _('BOOKMARK')) |
|
117 | " bookmark"), _('BOOKMARK')), | |
|
118 | ('', 'soft', None, | |||
|
119 | _("simply drop changesets from visible history (EXPERIMENTAL)")), | |||
|
120 | ], | |||
114 | _('hg strip [-k] [-f] [-B bookmark] [-r] REV...'), |
|
121 | _('hg strip [-k] [-f] [-B bookmark] [-r] REV...'), | |
115 | helpcategory=command.CATEGORY_MAINTENANCE) |
|
122 | helpcategory=command.CATEGORY_MAINTENANCE) | |
116 | def stripcmd(ui, repo, *revs, **opts): |
|
123 | def stripcmd(ui, repo, *revs, **opts): | |
@@ -235,6 +242,7 b' def stripcmd(ui, repo, *revs, **opts):' | |||||
235 |
|
242 | |||
236 |
|
243 | |||
237 | strip(ui, repo, revs, backup=backup, update=update, |
|
244 | strip(ui, repo, revs, backup=backup, update=update, | |
238 |
force=opts.get('force'), bookmarks=bookmarks |
|
245 | force=opts.get('force'), bookmarks=bookmarks, | |
|
246 | soft=opts['soft']) | |||
239 |
|
247 | |||
240 | return 0 |
|
248 | return 0 |
@@ -252,6 +252,24 b' def strip(ui, repo, nodelist, backup=Tru' | |||||
252 | # extensions can use it |
|
252 | # extensions can use it | |
253 | return backupfile |
|
253 | return backupfile | |
254 |
|
254 | |||
|
255 | def softstrip(ui, repo, nodelist, backup=True, topic='backup'): | |||
|
256 | """perform a "soft" strip using the archived phase""" | |||
|
257 | tostrip = [c.node() for c in repo.set('sort(%ln::)', nodelist)] | |||
|
258 | if not tostrip: | |||
|
259 | return None | |||
|
260 | ||||
|
261 | newbmtarget, updatebm = _bookmarkmovements(repo, tostrip) | |||
|
262 | if backup: | |||
|
263 | node = tostrip[0] | |||
|
264 | backupfile = _createstripbackup(repo, tostrip, node, topic) | |||
|
265 | ||||
|
266 | with repo.transaction('strip') as tr: | |||
|
267 | phases.retractboundary(repo, tr, phases.archived, tostrip) | |||
|
268 | bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm] | |||
|
269 | repo._bookmarks.applychanges(repo, tr, bmchanges) | |||
|
270 | return backupfile | |||
|
271 | ||||
|
272 | ||||
255 | def _bookmarkmovements(repo, tostrip): |
|
273 | def _bookmarkmovements(repo, tostrip): | |
256 | # compute necessary bookmark movement |
|
274 | # compute necessary bookmark movement | |
257 | bm = repo._bookmarks |
|
275 | bm = repo._bookmarks |
General Comments 0
You need to be logged in to leave comments.
Login now