Show More
@@ -1,222 +1,219 | |||
|
1 | 1 | """strip changesets and their descendents from history |
|
2 | 2 | |
|
3 | 3 | This extension allows you to strip changesets and all their descendants from the |
|
4 | 4 | repository. See the command help for details. |
|
5 | 5 | """ |
|
6 | 6 | from mercurial.i18n import _ |
|
7 | 7 | from mercurial.node import nullid |
|
8 | 8 | from mercurial.lock import release |
|
9 | 9 | from mercurial import cmdutil, hg, scmutil, util |
|
10 | 10 | from mercurial import repair, bookmarks |
|
11 | 11 | |
|
12 | 12 | cmdtable = {} |
|
13 | 13 | command = cmdutil.command(cmdtable) |
|
14 | 14 | testedwith = 'internal' |
|
15 | 15 | |
|
16 | 16 | def checksubstate(repo, baserev=None): |
|
17 | 17 | '''return list of subrepos at a different revision than substate. |
|
18 | 18 | Abort if any subrepos have uncommitted changes.''' |
|
19 | 19 | inclsubs = [] |
|
20 | 20 | wctx = repo[None] |
|
21 | 21 | if baserev: |
|
22 | 22 | bctx = repo[baserev] |
|
23 | 23 | else: |
|
24 | 24 | bctx = wctx.parents()[0] |
|
25 | 25 | for s in sorted(wctx.substate): |
|
26 | 26 | if wctx.sub(s).dirty(True): |
|
27 | 27 | raise util.Abort( |
|
28 | 28 | _("uncommitted changes in subrepository %s") % s) |
|
29 | 29 | elif s not in bctx.substate or bctx.sub(s).dirty(): |
|
30 | 30 | inclsubs.append(s) |
|
31 | 31 | return inclsubs |
|
32 | 32 | |
|
33 | 33 | def checklocalchanges(repo, force=False, excsuffix=''): |
|
34 | 34 | cmdutil.checkunfinished(repo) |
|
35 | 35 | m, a, r, d = repo.status()[:4] |
|
36 | 36 | if not force: |
|
37 | 37 | if (m or a or r or d): |
|
38 | 38 | _("local changes found") # i18n tool detection |
|
39 | 39 | raise util.Abort(_("local changes found" + excsuffix)) |
|
40 | 40 | if checksubstate(repo): |
|
41 | 41 | _("local changed subrepos found") # i18n tool detection |
|
42 | 42 | raise util.Abort(_("local changed subrepos found" + excsuffix)) |
|
43 | 43 | return m, a, r, d |
|
44 | 44 | |
|
45 | 45 | def strip(ui, repo, revs, update=True, backup="all", force=None, bookmark=None): |
|
46 | 46 | wlock = lock = None |
|
47 | 47 | try: |
|
48 | 48 | wlock = repo.wlock() |
|
49 | 49 | lock = repo.lock() |
|
50 | 50 | |
|
51 | 51 | if update: |
|
52 | 52 | checklocalchanges(repo, force=force) |
|
53 | 53 | urev, p2 = repo.changelog.parents(revs[0]) |
|
54 | 54 | if (util.safehasattr(repo, 'mq') and |
|
55 | 55 | p2 != nullid |
|
56 | 56 | and p2 in [x.node for x in repo.mq.applied]): |
|
57 | 57 | urev = p2 |
|
58 | 58 | hg.clean(repo, urev) |
|
59 | 59 | repo.dirstate.write() |
|
60 | 60 | |
|
61 | 61 | repair.strip(ui, repo, revs, backup) |
|
62 | 62 | |
|
63 | 63 | marks = repo._bookmarks |
|
64 | 64 | if bookmark: |
|
65 | 65 | if bookmark == repo._bookmarkcurrent: |
|
66 | 66 | bookmarks.unsetcurrent(repo) |
|
67 | 67 | del marks[bookmark] |
|
68 | 68 | marks.write() |
|
69 | 69 | ui.write(_("bookmark '%s' deleted\n") % bookmark) |
|
70 | 70 | finally: |
|
71 | 71 | release(lock, wlock) |
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | @command("strip", |
|
75 | 75 | [ |
|
76 | 76 | ('r', 'rev', [], _('strip specified revision (optional, ' |
|
77 | 77 | 'can specify revisions without this ' |
|
78 | 78 | 'option)'), _('REV')), |
|
79 | 79 | ('f', 'force', None, _('force removal of changesets, discard ' |
|
80 | 80 | 'uncommitted changes (no backup)')), |
|
81 | ('b', 'backup', None, _('bundle only changesets with local revision' | |
|
82 | ' number greater than REV which are not' | |
|
83 | ' descendants of REV (DEPRECATED)')), | |
|
84 | 81 | ('', 'no-backup', None, _('no backups')), |
|
85 | 82 | ('', 'nobackup', None, _('no backups (DEPRECATED)')), |
|
86 | 83 | ('n', '', None, _('ignored (DEPRECATED)')), |
|
87 | 84 | ('k', 'keep', None, _("do not modify working copy during strip")), |
|
88 | 85 | ('B', 'bookmark', '', _("remove revs only reachable from given" |
|
89 | 86 | " bookmark"))], |
|
90 | 87 | _('hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...')) |
|
91 | 88 | def stripcmd(ui, repo, *revs, **opts): |
|
92 | 89 | """strip changesets and all their descendants from the repository |
|
93 | 90 | |
|
94 | 91 | The strip command removes the specified changesets and all their |
|
95 | 92 | descendants. If the working directory has uncommitted changes, the |
|
96 | 93 | operation is aborted unless the --force flag is supplied, in which |
|
97 | 94 | case changes will be discarded. |
|
98 | 95 | |
|
99 | 96 | If a parent of the working directory is stripped, then the working |
|
100 | 97 | directory will automatically be updated to the most recent |
|
101 | 98 | available ancestor of the stripped parent after the operation |
|
102 | 99 | completes. |
|
103 | 100 | |
|
104 | 101 | Any stripped changesets are stored in ``.hg/strip-backup`` as a |
|
105 | 102 | bundle (see :hg:`help bundle` and :hg:`help unbundle`). They can |
|
106 | 103 | be restored by running :hg:`unbundle .hg/strip-backup/BUNDLE`, |
|
107 | 104 | where BUNDLE is the bundle file created by the strip. Note that |
|
108 | 105 | the local revision numbers will in general be different after the |
|
109 | 106 | restore. |
|
110 | 107 | |
|
111 | 108 | Use the --no-backup option to discard the backup bundle once the |
|
112 | 109 | operation completes. |
|
113 | 110 | |
|
114 | 111 | Strip is not a history-rewriting operation and can be used on |
|
115 | 112 | changesets in the public phase. But if the stripped changesets have |
|
116 | 113 | been pushed to a remote repository you will likely pull them again. |
|
117 | 114 | |
|
118 | 115 | Return 0 on success. |
|
119 | 116 | """ |
|
120 | 117 | backup = 'all' |
|
121 | 118 | if opts.get('backup'): |
|
122 | 119 | backup = 'strip' |
|
123 | 120 | elif opts.get('no_backup') or opts.get('nobackup'): |
|
124 | 121 | backup = 'none' |
|
125 | 122 | |
|
126 | 123 | cl = repo.changelog |
|
127 | 124 | revs = list(revs) + opts.get('rev') |
|
128 | 125 | revs = set(scmutil.revrange(repo, revs)) |
|
129 | 126 | |
|
130 | 127 | wlock = repo.wlock() |
|
131 | 128 | try: |
|
132 | 129 | if opts.get('bookmark'): |
|
133 | 130 | mark = opts.get('bookmark') |
|
134 | 131 | marks = repo._bookmarks |
|
135 | 132 | if mark not in marks: |
|
136 | 133 | raise util.Abort(_("bookmark '%s' not found") % mark) |
|
137 | 134 | |
|
138 | 135 | # If the requested bookmark is not the only one pointing to a |
|
139 | 136 | # a revision we have to only delete the bookmark and not strip |
|
140 | 137 | # anything. revsets cannot detect that case. |
|
141 | 138 | uniquebm = True |
|
142 | 139 | for m, n in marks.iteritems(): |
|
143 | 140 | if m != mark and n == repo[mark].node(): |
|
144 | 141 | uniquebm = False |
|
145 | 142 | break |
|
146 | 143 | if uniquebm: |
|
147 | 144 | rsrevs = repo.revs("ancestors(bookmark(%s)) - " |
|
148 | 145 | "ancestors(head() and not bookmark(%s)) - " |
|
149 | 146 | "ancestors(bookmark() and not bookmark(%s))", |
|
150 | 147 | mark, mark, mark) |
|
151 | 148 | revs.update(set(rsrevs)) |
|
152 | 149 | if not revs: |
|
153 | 150 | del marks[mark] |
|
154 | 151 | marks.write() |
|
155 | 152 | ui.write(_("bookmark '%s' deleted\n") % mark) |
|
156 | 153 | |
|
157 | 154 | if not revs: |
|
158 | 155 | raise util.Abort(_('empty revision set')) |
|
159 | 156 | |
|
160 | 157 | descendants = set(cl.descendants(revs)) |
|
161 | 158 | strippedrevs = revs.union(descendants) |
|
162 | 159 | roots = revs.difference(descendants) |
|
163 | 160 | |
|
164 | 161 | update = False |
|
165 | 162 | # if one of the wdir parent is stripped we'll need |
|
166 | 163 | # to update away to an earlier revision |
|
167 | 164 | for p in repo.dirstate.parents(): |
|
168 | 165 | if p != nullid and cl.rev(p) in strippedrevs: |
|
169 | 166 | update = True |
|
170 | 167 | break |
|
171 | 168 | |
|
172 | 169 | rootnodes = set(cl.node(r) for r in roots) |
|
173 | 170 | |
|
174 | 171 | q = getattr(repo, 'mq', None) |
|
175 | 172 | if q is not None and q.applied: |
|
176 | 173 | # refresh queue state if we're about to strip |
|
177 | 174 | # applied patches |
|
178 | 175 | if cl.rev(repo.lookup('qtip')) in strippedrevs: |
|
179 | 176 | q.applieddirty = True |
|
180 | 177 | start = 0 |
|
181 | 178 | end = len(q.applied) |
|
182 | 179 | for i, statusentry in enumerate(q.applied): |
|
183 | 180 | if statusentry.node in rootnodes: |
|
184 | 181 | # if one of the stripped roots is an applied |
|
185 | 182 | # patch, only part of the queue is stripped |
|
186 | 183 | start = i |
|
187 | 184 | break |
|
188 | 185 | del q.applied[start:end] |
|
189 | 186 | q.savedirty() |
|
190 | 187 | |
|
191 | 188 | revs = sorted(rootnodes) |
|
192 | 189 | if update and opts.get('keep'): |
|
193 | 190 | urev, p2 = repo.changelog.parents(revs[0]) |
|
194 | 191 | if (util.safehasattr(repo, 'mq') and p2 != nullid |
|
195 | 192 | and p2 in [x.node for x in repo.mq.applied]): |
|
196 | 193 | urev = p2 |
|
197 | 194 | uctx = repo[urev] |
|
198 | 195 | |
|
199 | 196 | # only reset the dirstate for files that would actually change |
|
200 | 197 | # between the working context and uctx |
|
201 | 198 | descendantrevs = repo.revs("%s::." % uctx.rev()) |
|
202 | 199 | changedfiles = [] |
|
203 | 200 | for rev in descendantrevs: |
|
204 | 201 | # blindly reset the files, regardless of what actually changed |
|
205 | 202 | changedfiles.extend(repo[rev].files()) |
|
206 | 203 | |
|
207 | 204 | # reset files that only changed in the dirstate too |
|
208 | 205 | dirstate = repo.dirstate |
|
209 | 206 | dirchanges = [f for f in dirstate if dirstate[f] != 'n'] |
|
210 | 207 | changedfiles.extend(dirchanges) |
|
211 | 208 | |
|
212 | 209 | repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles) |
|
213 | 210 | repo.dirstate.write() |
|
214 | 211 | update = False |
|
215 | 212 | |
|
216 | 213 | |
|
217 | 214 | strip(ui, repo, revs, backup=backup, update=update, |
|
218 | 215 | force=opts.get('force'), bookmark=opts.get('bookmark')) |
|
219 | 216 | finally: |
|
220 | 217 | wlock.release() |
|
221 | 218 | |
|
222 | 219 | return 0 |
@@ -1,527 +1,551 | |||
|
1 | 1 | $ echo "[extensions]" >> $HGRCPATH |
|
2 | 2 | $ echo "strip=" >> $HGRCPATH |
|
3 | 3 | |
|
4 | 4 | $ restore() { |
|
5 | 5 | > hg unbundle -q .hg/strip-backup/* |
|
6 | 6 | > rm .hg/strip-backup/* |
|
7 | 7 | > } |
|
8 | 8 | $ teststrip() { |
|
9 | 9 | > hg up -C $1 |
|
10 | 10 | > echo % before update $1, strip $2 |
|
11 | 11 | > hg parents |
|
12 | 12 | > hg --traceback strip $2 |
|
13 | 13 | > echo % after update $1, strip $2 |
|
14 | 14 | > hg parents |
|
15 | 15 | > restore |
|
16 | 16 | > } |
|
17 | 17 | |
|
18 | 18 | $ hg init test |
|
19 | 19 | $ cd test |
|
20 | 20 | |
|
21 | 21 | $ echo foo > bar |
|
22 | 22 | $ hg ci -Ama |
|
23 | 23 | adding bar |
|
24 | 24 | |
|
25 | 25 | $ echo more >> bar |
|
26 | 26 | $ hg ci -Amb |
|
27 | 27 | |
|
28 | 28 | $ echo blah >> bar |
|
29 | 29 | $ hg ci -Amc |
|
30 | 30 | |
|
31 | 31 | $ hg up 1 |
|
32 | 32 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
33 | 33 | $ echo blah >> bar |
|
34 | 34 | $ hg ci -Amd |
|
35 | 35 | created new head |
|
36 | 36 | |
|
37 | 37 | $ echo final >> bar |
|
38 | 38 | $ hg ci -Ame |
|
39 | 39 | |
|
40 | 40 | $ hg log |
|
41 | 41 | changeset: 4:443431ffac4f |
|
42 | 42 | tag: tip |
|
43 | 43 | user: test |
|
44 | 44 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
45 | 45 | summary: e |
|
46 | 46 | |
|
47 | 47 | changeset: 3:65bd5f99a4a3 |
|
48 | 48 | parent: 1:ef3a871183d7 |
|
49 | 49 | user: test |
|
50 | 50 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
51 | 51 | summary: d |
|
52 | 52 | |
|
53 | 53 | changeset: 2:264128213d29 |
|
54 | 54 | user: test |
|
55 | 55 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
56 | 56 | summary: c |
|
57 | 57 | |
|
58 | 58 | changeset: 1:ef3a871183d7 |
|
59 | 59 | user: test |
|
60 | 60 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
61 | 61 | summary: b |
|
62 | 62 | |
|
63 | 63 | changeset: 0:9ab35a2d17cb |
|
64 | 64 | user: test |
|
65 | 65 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
66 | 66 | summary: a |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | $ teststrip 4 4 |
|
70 | 70 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
71 | 71 | % before update 4, strip 4 |
|
72 | 72 | changeset: 4:443431ffac4f |
|
73 | 73 | tag: tip |
|
74 | 74 | user: test |
|
75 | 75 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
76 | 76 | summary: e |
|
77 | 77 | |
|
78 | 78 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
79 | 79 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
80 | 80 | % after update 4, strip 4 |
|
81 | 81 | changeset: 3:65bd5f99a4a3 |
|
82 | 82 | tag: tip |
|
83 | 83 | parent: 1:ef3a871183d7 |
|
84 | 84 | user: test |
|
85 | 85 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
86 | 86 | summary: d |
|
87 | 87 | |
|
88 | 88 | $ teststrip 4 3 |
|
89 | 89 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 | 90 | % before update 4, strip 3 |
|
91 | 91 | changeset: 4:443431ffac4f |
|
92 | 92 | tag: tip |
|
93 | 93 | user: test |
|
94 | 94 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
95 | 95 | summary: e |
|
96 | 96 | |
|
97 | 97 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
98 | 98 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
99 | 99 | % after update 4, strip 3 |
|
100 | 100 | changeset: 1:ef3a871183d7 |
|
101 | 101 | user: test |
|
102 | 102 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
103 | 103 | summary: b |
|
104 | 104 | |
|
105 | 105 | $ teststrip 1 4 |
|
106 | 106 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
107 | 107 | % before update 1, strip 4 |
|
108 | 108 | changeset: 1:ef3a871183d7 |
|
109 | 109 | user: test |
|
110 | 110 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
111 | 111 | summary: b |
|
112 | 112 | |
|
113 | 113 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
114 | 114 | % after update 1, strip 4 |
|
115 | 115 | changeset: 1:ef3a871183d7 |
|
116 | 116 | user: test |
|
117 | 117 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
118 | 118 | summary: b |
|
119 | 119 | |
|
120 | 120 | $ teststrip 4 2 |
|
121 | 121 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
122 | 122 | % before update 4, strip 2 |
|
123 | 123 | changeset: 4:443431ffac4f |
|
124 | 124 | tag: tip |
|
125 | 125 | user: test |
|
126 | 126 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
127 | 127 | summary: e |
|
128 | 128 | |
|
129 | 129 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
130 | 130 | % after update 4, strip 2 |
|
131 | 131 | changeset: 3:443431ffac4f |
|
132 | 132 | tag: tip |
|
133 | 133 | user: test |
|
134 | 134 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
135 | 135 | summary: e |
|
136 | 136 | |
|
137 | 137 | $ teststrip 4 1 |
|
138 | 138 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
139 | 139 | % before update 4, strip 1 |
|
140 | 140 | changeset: 4:264128213d29 |
|
141 | 141 | tag: tip |
|
142 | 142 | parent: 1:ef3a871183d7 |
|
143 | 143 | user: test |
|
144 | 144 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
145 | 145 | summary: c |
|
146 | 146 | |
|
147 | 147 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
148 | 148 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
149 | 149 | % after update 4, strip 1 |
|
150 | 150 | changeset: 0:9ab35a2d17cb |
|
151 | 151 | tag: tip |
|
152 | 152 | user: test |
|
153 | 153 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
154 | 154 | summary: a |
|
155 | 155 | |
|
156 | 156 | $ teststrip null 4 |
|
157 | 157 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
158 | 158 | % before update null, strip 4 |
|
159 | 159 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
160 | 160 | % after update null, strip 4 |
|
161 | 161 | |
|
162 | 162 | $ hg log |
|
163 | 163 | changeset: 4:264128213d29 |
|
164 | 164 | tag: tip |
|
165 | 165 | parent: 1:ef3a871183d7 |
|
166 | 166 | user: test |
|
167 | 167 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
168 | 168 | summary: c |
|
169 | 169 | |
|
170 | 170 | changeset: 3:443431ffac4f |
|
171 | 171 | user: test |
|
172 | 172 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
173 | 173 | summary: e |
|
174 | 174 | |
|
175 | 175 | changeset: 2:65bd5f99a4a3 |
|
176 | 176 | user: test |
|
177 | 177 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
178 | 178 | summary: d |
|
179 | 179 | |
|
180 | 180 | changeset: 1:ef3a871183d7 |
|
181 | 181 | user: test |
|
182 | 182 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
183 | 183 | summary: b |
|
184 | 184 | |
|
185 | 185 | changeset: 0:9ab35a2d17cb |
|
186 | 186 | user: test |
|
187 | 187 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
188 | 188 | summary: a |
|
189 | 189 | |
|
190 | 190 | |
|
191 | 191 | $ hg up -C 2 |
|
192 | 192 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
193 | 193 | $ hg merge 4 |
|
194 | 194 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
195 | 195 | (branch merge, don't forget to commit) |
|
196 | 196 | |
|
197 | 197 | before strip of merge parent |
|
198 | 198 | |
|
199 | 199 | $ hg parents |
|
200 | 200 | changeset: 2:65bd5f99a4a3 |
|
201 | 201 | user: test |
|
202 | 202 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
203 | 203 | summary: d |
|
204 | 204 | |
|
205 | 205 | changeset: 4:264128213d29 |
|
206 | 206 | tag: tip |
|
207 | 207 | parent: 1:ef3a871183d7 |
|
208 | 208 | user: test |
|
209 | 209 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
210 | 210 | summary: c |
|
211 | 211 | |
|
212 | 212 | $ hg strip 4 |
|
213 | 213 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
214 | 214 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
215 | 215 | |
|
216 | 216 | after strip of merge parent |
|
217 | 217 | |
|
218 | 218 | $ hg parents |
|
219 | 219 | changeset: 1:ef3a871183d7 |
|
220 | 220 | user: test |
|
221 | 221 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
222 | 222 | summary: b |
|
223 | 223 | |
|
224 | 224 | $ restore |
|
225 | 225 | |
|
226 | 226 | $ hg up |
|
227 | 227 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
228 | 228 | $ hg log -G |
|
229 | 229 | @ changeset: 4:264128213d29 |
|
230 | 230 | | tag: tip |
|
231 | 231 | | parent: 1:ef3a871183d7 |
|
232 | 232 | | user: test |
|
233 | 233 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
234 | 234 | | summary: c |
|
235 | 235 | | |
|
236 | 236 | | o changeset: 3:443431ffac4f |
|
237 | 237 | | | user: test |
|
238 | 238 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
239 | 239 | | | summary: e |
|
240 | 240 | | | |
|
241 | 241 | | o changeset: 2:65bd5f99a4a3 |
|
242 | 242 | |/ user: test |
|
243 | 243 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
244 | 244 | | summary: d |
|
245 | 245 | | |
|
246 | 246 | o changeset: 1:ef3a871183d7 |
|
247 | 247 | | user: test |
|
248 | 248 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
249 | 249 | | summary: b |
|
250 | 250 | | |
|
251 | 251 | o changeset: 0:9ab35a2d17cb |
|
252 | 252 | user: test |
|
253 | 253 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
254 | 254 | summary: a |
|
255 | 255 | |
|
256 | 256 | |
|
257 | 257 | 2 is parent of 3, only one strip should happen |
|
258 | 258 | |
|
259 | 259 | $ hg strip "roots(2)" 3 |
|
260 | 260 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
261 | 261 | $ hg log -G |
|
262 | 262 | @ changeset: 2:264128213d29 |
|
263 | 263 | | tag: tip |
|
264 | 264 | | user: test |
|
265 | 265 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
266 | 266 | | summary: c |
|
267 | 267 | | |
|
268 | 268 | o changeset: 1:ef3a871183d7 |
|
269 | 269 | | user: test |
|
270 | 270 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
271 | 271 | | summary: b |
|
272 | 272 | | |
|
273 | 273 | o changeset: 0:9ab35a2d17cb |
|
274 | 274 | user: test |
|
275 | 275 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
276 | 276 | summary: a |
|
277 | 277 | |
|
278 | 278 | $ restore |
|
279 | 279 | $ hg log -G |
|
280 | 280 | o changeset: 4:443431ffac4f |
|
281 | 281 | | tag: tip |
|
282 | 282 | | user: test |
|
283 | 283 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
284 | 284 | | summary: e |
|
285 | 285 | | |
|
286 | 286 | o changeset: 3:65bd5f99a4a3 |
|
287 | 287 | | parent: 1:ef3a871183d7 |
|
288 | 288 | | user: test |
|
289 | 289 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
290 | 290 | | summary: d |
|
291 | 291 | | |
|
292 | 292 | | @ changeset: 2:264128213d29 |
|
293 | 293 | |/ user: test |
|
294 | 294 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
295 | 295 | | summary: c |
|
296 | 296 | | |
|
297 | 297 | o changeset: 1:ef3a871183d7 |
|
298 | 298 | | user: test |
|
299 | 299 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
300 | 300 | | summary: b |
|
301 | 301 | | |
|
302 | 302 | o changeset: 0:9ab35a2d17cb |
|
303 | 303 | user: test |
|
304 | 304 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
305 | 305 | summary: a |
|
306 | 306 | |
|
307 | 307 | |
|
308 | 308 | 2 different branches: 2 strips |
|
309 | 309 | |
|
310 | 310 | $ hg strip 2 4 |
|
311 | 311 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
312 | 312 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
313 | 313 | $ hg log -G |
|
314 | 314 | o changeset: 2:65bd5f99a4a3 |
|
315 | 315 | | tag: tip |
|
316 | 316 | | user: test |
|
317 | 317 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
318 | 318 | | summary: d |
|
319 | 319 | | |
|
320 | 320 | @ changeset: 1:ef3a871183d7 |
|
321 | 321 | | user: test |
|
322 | 322 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
323 | 323 | | summary: b |
|
324 | 324 | | |
|
325 | 325 | o changeset: 0:9ab35a2d17cb |
|
326 | 326 | user: test |
|
327 | 327 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
328 | 328 | summary: a |
|
329 | 329 | |
|
330 | 330 | $ restore |
|
331 | 331 | |
|
332 | 332 | 2 different branches and a common ancestor: 1 strip |
|
333 | 333 | |
|
334 | 334 | $ hg strip 1 "2|4" |
|
335 | 335 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
336 | 336 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
337 | 337 | $ restore |
|
338 | 338 | |
|
339 | 339 | verify fncache is kept up-to-date |
|
340 | 340 | |
|
341 | 341 | $ touch a |
|
342 | 342 | $ hg ci -qAm a |
|
343 | 343 | $ cat .hg/store/fncache | sort |
|
344 | 344 | data/a.i |
|
345 | 345 | data/bar.i |
|
346 | 346 | $ hg strip tip |
|
347 | 347 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
348 | 348 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
349 | 349 | $ cat .hg/store/fncache |
|
350 | 350 | data/bar.i |
|
351 | 351 | |
|
352 | 352 | stripping an empty revset |
|
353 | 353 | |
|
354 | 354 | $ hg strip "1 and not 1" |
|
355 | 355 | abort: empty revision set |
|
356 | 356 | [255] |
|
357 | 357 | |
|
358 | 358 | remove branchy history for qimport tests |
|
359 | 359 | |
|
360 | 360 | $ hg strip 3 |
|
361 | 361 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
362 | 362 | |
|
363 | 363 | |
|
364 | 364 | strip of applied mq should cleanup status file |
|
365 | 365 | |
|
366 | 366 | $ echo "mq=" >> $HGRCPATH |
|
367 | 367 | $ hg up -C 3 |
|
368 | 368 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
369 | 369 | $ echo fooagain >> bar |
|
370 | 370 | $ hg ci -mf |
|
371 | 371 | $ hg qimport -r tip:2 |
|
372 | 372 | |
|
373 | 373 | applied patches before strip |
|
374 | 374 | |
|
375 | 375 | $ hg qapplied |
|
376 | 376 | 2.diff |
|
377 | 377 | 3.diff |
|
378 | 378 | 4.diff |
|
379 | 379 | |
|
380 | 380 | stripping revision in queue |
|
381 | 381 | |
|
382 | 382 | $ hg strip 3 |
|
383 | 383 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
384 | 384 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
385 | 385 | |
|
386 | 386 | applied patches after stripping rev in queue |
|
387 | 387 | |
|
388 | 388 | $ hg qapplied |
|
389 | 389 | 2.diff |
|
390 | 390 | |
|
391 | 391 | stripping ancestor of queue |
|
392 | 392 | |
|
393 | 393 | $ hg strip 1 |
|
394 | 394 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
395 | 395 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
396 | 396 | |
|
397 | 397 | applied patches after stripping ancestor of queue |
|
398 | 398 | |
|
399 | 399 | $ hg qapplied |
|
400 | 400 | |
|
401 | 401 | Verify strip protects against stripping wc parent when there are uncommitted mods |
|
402 | 402 | |
|
403 | 403 | $ echo b > b |
|
404 | 404 | $ hg add b |
|
405 | 405 | $ hg ci -m 'b' |
|
406 | 406 | $ hg log --graph |
|
407 | 407 | @ changeset: 1:7519abd79d14 |
|
408 | 408 | | tag: tip |
|
409 | 409 | | user: test |
|
410 | 410 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
411 | 411 | | summary: b |
|
412 | 412 | | |
|
413 | 413 | o changeset: 0:9ab35a2d17cb |
|
414 | 414 | user: test |
|
415 | 415 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
416 | 416 | summary: a |
|
417 | 417 | |
|
418 | 418 | |
|
419 | 419 | $ echo c > b |
|
420 | 420 | $ echo c > bar |
|
421 | 421 | $ hg strip tip |
|
422 | 422 | abort: local changes found |
|
423 | 423 | [255] |
|
424 | 424 | $ hg strip tip --keep |
|
425 | 425 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
426 | 426 | $ hg log --graph |
|
427 | 427 | @ changeset: 0:9ab35a2d17cb |
|
428 | 428 | tag: tip |
|
429 | 429 | user: test |
|
430 | 430 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
431 | 431 | summary: a |
|
432 | 432 | |
|
433 | 433 | $ hg status |
|
434 | 434 | M bar |
|
435 | 435 | ? b |
|
436 | 436 | |
|
437 | 437 | Strip adds, removes, modifies with --keep |
|
438 | 438 | |
|
439 | 439 | $ touch b |
|
440 | 440 | $ hg add b |
|
441 | 441 | $ hg commit -mb |
|
442 | 442 | $ touch c |
|
443 | 443 | |
|
444 | 444 | ... with a clean working dir |
|
445 | 445 | |
|
446 | 446 | $ hg add c |
|
447 | 447 | $ hg rm bar |
|
448 | 448 | $ hg commit -mc |
|
449 | 449 | $ hg status |
|
450 | 450 | $ hg strip --keep tip |
|
451 | 451 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
452 | 452 | $ hg status |
|
453 | 453 | ! bar |
|
454 | 454 | ? c |
|
455 | 455 | |
|
456 | 456 | ... with a dirty working dir |
|
457 | 457 | |
|
458 | 458 | $ hg add c |
|
459 | 459 | $ hg rm bar |
|
460 | 460 | $ hg commit -mc |
|
461 | 461 | $ hg status |
|
462 | 462 | $ echo b > b |
|
463 | 463 | $ echo d > d |
|
464 | 464 | $ hg strip --keep tip |
|
465 | 465 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
466 | 466 | $ hg status |
|
467 | 467 | M b |
|
468 | 468 | ! bar |
|
469 | 469 | ? c |
|
470 | 470 | ? d |
|
471 | 471 | $ cd .. |
|
472 | 472 | |
|
473 | 473 | stripping many nodes on a complex graph (issue3299) |
|
474 | 474 | |
|
475 | 475 | $ hg init issue3299 |
|
476 | 476 | $ cd issue3299 |
|
477 | 477 | $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a' |
|
478 | 478 | $ hg strip 'not ancestors(x)' |
|
479 | 479 | saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob) |
|
480 | 480 | |
|
481 | 481 | test hg strip -B bookmark |
|
482 | 482 | |
|
483 | 483 | $ cd .. |
|
484 | 484 | $ hg init bookmarks |
|
485 | 485 | $ cd bookmarks |
|
486 | 486 | $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b' |
|
487 | 487 | $ hg bookmark -r 'a' 'todelete' |
|
488 | 488 | $ hg bookmark -r 'b' 'B' |
|
489 | 489 | $ hg bookmark -r 'b' 'nostrip' |
|
490 | 490 | $ hg bookmark -r 'c' 'delete' |
|
491 | 491 | $ hg up -C todelete |
|
492 | 492 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
493 | 493 | (activating bookmark todelete) |
|
494 | 494 | $ hg strip -B nostrip |
|
495 | 495 | bookmark 'nostrip' deleted |
|
496 | 496 | abort: empty revision set |
|
497 | 497 | [255] |
|
498 | 498 | $ hg strip -B todelete |
|
499 | 499 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
500 | 500 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
501 | 501 | bookmark 'todelete' deleted |
|
502 | 502 | $ hg id -ir dcbb326fdec2 |
|
503 | 503 | abort: unknown revision 'dcbb326fdec2'! |
|
504 | 504 | [255] |
|
505 | 505 | $ hg id -ir d62d843c9a01 |
|
506 | 506 | d62d843c9a01 |
|
507 | 507 | $ hg bookmarks |
|
508 | 508 | B 9:ff43616e5d0f |
|
509 | 509 | delete 6:2702dd0c91e7 |
|
510 | 510 | $ hg strip -B delete |
|
511 | 511 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
512 | 512 | bookmark 'delete' deleted |
|
513 | 513 | $ hg id -ir 6:2702dd0c91e7 |
|
514 | 514 | abort: unknown revision '2702dd0c91e7'! |
|
515 | 515 | [255] |
|
516 | 516 | $ hg update B |
|
517 | 517 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
518 | 518 | (activating bookmark B) |
|
519 | 519 | $ echo a > a |
|
520 | 520 | $ hg add a |
|
521 | 521 | $ hg strip -B B |
|
522 | 522 | abort: local changes found |
|
523 | 523 | [255] |
|
524 | 524 | $ hg bookmarks |
|
525 | 525 | * B 6:ff43616e5d0f |
|
526 | 526 | |
|
527 | $ cd .. | |
|
527 | Make sure no one adds back a -b option: | |
|
528 | ||
|
529 | $ hg strip -b tip | |
|
530 | hg strip: option -b not recognized | |
|
531 | hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV... | |
|
532 | ||
|
533 | strip changesets and all their descendants from the repository | |
|
534 | ||
|
535 | use "hg help -e strip" to show help for the strip extension | |
|
536 | ||
|
537 | options: | |
|
538 | ||
|
539 | -r --rev REV [+] strip specified revision (optional, can specify revisions | |
|
540 | without this option) | |
|
541 | -f --force force removal of changesets, discard uncommitted changes | |
|
542 | (no backup) | |
|
543 | --no-backup no backups | |
|
544 | -k --keep do not modify working copy during strip | |
|
545 | -B --bookmark VALUE remove revs only reachable from given bookmark | |
|
546 | --mq operate on patch repository | |
|
547 | ||
|
548 | [+] marked option can be specified multiple times | |
|
549 | ||
|
550 | use "hg help strip" to show the full help text | |
|
551 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now