Show More
@@ -513,7 +513,7 b' class queue(object):' | |||||
513 |
|
513 | |||
514 | # apply failed, strip away that rev and merge. |
|
514 | # apply failed, strip away that rev and merge. | |
515 | hg.clean(repo, head) |
|
515 | hg.clean(repo, head) | |
516 | self.strip(repo, n, update=False, backup='strip') |
|
516 | self.strip(repo, [n], update=False, backup='strip') | |
517 |
|
517 | |||
518 | ctx = repo[rev] |
|
518 | ctx = repo[rev] | |
519 | ret = hg.merge(repo, rev) |
|
519 | ret = hg.merge(repo, rev) | |
@@ -895,7 +895,7 b' class queue(object):' | |||||
895 | finally: |
|
895 | finally: | |
896 | release(wlock) |
|
896 | release(wlock) | |
897 |
|
897 | |||
898 | def strip(self, repo, rev, update=True, backup="all", force=None): |
|
898 | def strip(self, repo, revs, update=True, backup="all", force=None): | |
899 | wlock = lock = None |
|
899 | wlock = lock = None | |
900 | try: |
|
900 | try: | |
901 | wlock = repo.wlock() |
|
901 | wlock = repo.wlock() | |
@@ -903,12 +903,13 b' class queue(object):' | |||||
903 |
|
903 | |||
904 | if update: |
|
904 | if update: | |
905 | self.check_localchanges(repo, force=force, refresh=False) |
|
905 | self.check_localchanges(repo, force=force, refresh=False) | |
906 | urev = self.qparents(repo, rev) |
|
906 | urev = self.qparents(repo, revs[0]) | |
907 | hg.clean(repo, urev) |
|
907 | hg.clean(repo, urev) | |
908 | repo.dirstate.write() |
|
908 | repo.dirstate.write() | |
909 |
|
909 | |||
910 | self.removeundo(repo) |
|
910 | self.removeundo(repo) | |
911 | repair.strip(self.ui, repo, rev, backup) |
|
911 | for rev in revs: | |
|
912 | repair.strip(self.ui, repo, rev, backup) | |||
912 | # strip may have unbundled a set of backed up revisions after |
|
913 | # strip may have unbundled a set of backed up revisions after | |
913 | # the actual strip |
|
914 | # the actual strip | |
914 | self.removeundo(repo) |
|
915 | self.removeundo(repo) | |
@@ -1197,7 +1198,7 b' class queue(object):' | |||||
1197 | for patch in reversed(self.applied[start:end]): |
|
1198 | for patch in reversed(self.applied[start:end]): | |
1198 | self.ui.status(_("popping %s\n") % patch.name) |
|
1199 | self.ui.status(_("popping %s\n") % patch.name) | |
1199 | del self.applied[start:end] |
|
1200 | del self.applied[start:end] | |
1200 | self.strip(repo, rev, update=False, backup='strip') |
|
1201 | self.strip(repo, [rev], update=False, backup='strip') | |
1201 | if self.applied: |
|
1202 | if self.applied: | |
1202 | self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
|
1203 | self.ui.write(_("now at: %s\n") % self.applied[-1].name) | |
1203 | else: |
|
1204 | else: | |
@@ -1377,7 +1378,7 b' class queue(object):' | |||||
1377 | repo.dirstate.setparents(*cparents) |
|
1378 | repo.dirstate.setparents(*cparents) | |
1378 | self.applied.pop() |
|
1379 | self.applied.pop() | |
1379 | self.applied_dirty = 1 |
|
1380 | self.applied_dirty = 1 | |
1380 | self.strip(repo, top, update=False, |
|
1381 | self.strip(repo, [top], update=False, | |
1381 | backup='strip') |
|
1382 | backup='strip') | |
1382 | except: |
|
1383 | except: | |
1383 | repo.dirstate.invalidate() |
|
1384 | repo.dirstate.invalidate() | |
@@ -1532,7 +1533,7 b' class queue(object):' | |||||
1532 | update = True |
|
1533 | update = True | |
1533 | else: |
|
1534 | else: | |
1534 | update = False |
|
1535 | update = False | |
1535 | self.strip(repo, rev, update=update, backup='strip') |
|
1536 | self.strip(repo, [rev], update=update, backup='strip') | |
1536 | if qpp: |
|
1537 | if qpp: | |
1537 | self.ui.warn(_("saved queue repository parents: %s %s\n") % |
|
1538 | self.ui.warn(_("saved queue repository parents: %s %s\n") % | |
1538 | (short(qpp[0]), short(qpp[1]))) |
|
1539 | (short(qpp[0]), short(qpp[1]))) | |
@@ -1934,7 +1935,7 b' def clone(ui, source, dest=None, **opts)' | |||||
1934 | if qbase: |
|
1935 | if qbase: | |
1935 | ui.note(_('stripping applied patches from destination ' |
|
1936 | ui.note(_('stripping applied patches from destination ' | |
1936 | 'repository\n')) |
|
1937 | 'repository\n')) | |
1937 | dr.mq.strip(dr, qbase, update=False, backup=None) |
|
1938 | dr.mq.strip(dr, [qbase], update=False, backup=None) | |
1938 | if not opts['noupdate']: |
|
1939 | if not opts['noupdate']: | |
1939 | ui.note(_('updating destination repository\n')) |
|
1940 | ui.note(_('updating destination repository\n')) | |
1940 | hg.update(dr, dr.changelog.tip()) |
|
1941 | hg.update(dr, dr.changelog.tip()) | |
@@ -2396,14 +2397,12 b' def save(ui, repo, **opts):' | |||||
2396 | pass |
|
2397 | pass | |
2397 | return 0 |
|
2398 | return 0 | |
2398 |
|
2399 | |||
2399 | def strip(ui, repo, rev, **opts): |
|
2400 | def strip(ui, repo, *revs, **opts): | |
2400 |
"""strip |
|
2401 | """strip changesets and all their descendants from the repository | |
2401 |
|
2402 | |||
2402 |
The strip command removes |
|
2403 | The strip command removes the specified changesets and all their | |
2403 | number is greater than or equal to REV, and then restores any |
|
2404 | descendants. If the working directory has uncommitted changes, | |
2404 | changesets that are not descendants of REV. If the working |
|
2405 | the operation is aborted unless the --force flag is supplied. | |
2405 | directory has uncommitted changes, the operation is aborted unless |
|
|||
2406 | the --force flag is supplied. |
|
|||
2407 |
|
2406 | |||
2408 | If a parent of the working directory is stripped, then the working |
|
2407 | If a parent of the working directory is stripped, then the working | |
2409 | directory will automatically be updated to the most recent |
|
2408 | directory will automatically be updated to the most recent | |
@@ -2426,30 +2425,42 b' def strip(ui, repo, rev, **opts):' | |||||
2426 | elif opts['nobackup']: |
|
2425 | elif opts['nobackup']: | |
2427 | backup = 'none' |
|
2426 | backup = 'none' | |
2428 |
|
2427 | |||
2429 | rev = repo.lookup(rev) |
|
|||
2430 | p = repo.dirstate.parents() |
|
|||
2431 | cl = repo.changelog |
|
2428 | cl = repo.changelog | |
2432 | update = True |
|
2429 | revs = set(cl.rev(repo.lookup(r)) for r in revs) | |
2433 | if p[0] == nullid: |
|
2430 | ||
2434 | update = False |
|
2431 | descendants = set(cl.descendants(*revs)) | |
2435 | elif p[1] == nullid and rev != cl.ancestor(p[0], rev): |
|
2432 | strippedrevs = revs.union(descendants) | |
2436 | update = False |
|
2433 | roots = revs.difference(descendants) | |
2437 | elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)): |
|
2434 | ||
2438 |
|
|
2435 | update = False | |
|
2436 | # if one of the wdir parent is stripped we'll need | |||
|
2437 | # to update away to an earlier revision | |||
|
2438 | for p in repo.dirstate.parents(): | |||
|
2439 | if p != nullid and cl.rev(p) in strippedrevs: | |||
|
2440 | update = True | |||
|
2441 | break | |||
|
2442 | ||||
|
2443 | rootnodes = set(cl.node(r) for r in roots) | |||
2439 |
|
2444 | |||
2440 | q = repo.mq |
|
2445 | q = repo.mq | |
2441 | if q.applied: |
|
2446 | if q.applied: | |
2442 | if rev == cl.ancestor(repo.lookup('qtip'), rev): |
|
2447 | # refresh queue state if we're about to strip | |
|
2448 | # applied patches | |||
|
2449 | if cl.rev(repo.lookup('qtip')) in strippedrevs: | |||
2443 | q.applied_dirty = True |
|
2450 | q.applied_dirty = True | |
2444 | start = 0 |
|
2451 | start = 0 | |
2445 | end = len(q.applied) |
|
2452 | end = len(q.applied) | |
2446 | applied_list = [i.node for i in q.applied] |
|
2453 | for i, statusentry in enumerate(q.applied): | |
2447 | if rev in applied_list: |
|
2454 | if statusentry.node in rootnodes: | |
2448 | start = applied_list.index(rev) |
|
2455 | # if one of the stripped roots is an applied | |
|
2456 | # patch, only part of the queue is stripped | |||
|
2457 | start = i | |||
|
2458 | break | |||
2449 | del q.applied[start:end] |
|
2459 | del q.applied[start:end] | |
2450 | q.save_dirty() |
|
2460 | q.save_dirty() | |
2451 |
|
2461 | |||
2452 |
repo.mq.strip(repo, |
|
2462 | repo.mq.strip(repo, list(rootnodes), backup=backup, update=update, | |
|
2463 | force=opts['force']) | |||
2453 | return 0 |
|
2464 | return 0 | |
2454 |
|
2465 | |||
2455 | def select(ui, repo, *args, **opts): |
|
2466 | def select(ui, repo, *args, **opts): | |
@@ -3008,7 +3019,7 b' cmdtable = {' | |||||
3008 | ' number greater than REV which are not' |
|
3019 | ' number greater than REV which are not' | |
3009 | ' descendants of REV (DEPRECATED)')), |
|
3020 | ' descendants of REV (DEPRECATED)')), | |
3010 | ('n', 'nobackup', None, _('no backups'))], |
|
3021 | ('n', 'nobackup', None, _('no backups'))], | |
3011 | _('hg strip [-f] [-n] REV')), |
|
3022 | _('hg strip [-f] [-n] REV...')), | |
3012 | "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
|
3023 | "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), | |
3013 | "qunapplied": |
|
3024 | "qunapplied": | |
3014 | (unapplied, |
|
3025 | (unapplied, |
@@ -4,16 +4,20 b'' | |||||
4 |
|
4 | |||
5 | echo "[extensions]" >> $HGRCPATH |
|
5 | echo "[extensions]" >> $HGRCPATH | |
6 | echo "mq=" >> $HGRCPATH |
|
6 | echo "mq=" >> $HGRCPATH | |
|
7 | echo "graphlog=" >> $HGRCPATH | |||
7 |
|
8 | |||
|
9 | restore() { | |||
|
10 | hg unbundle -q .hg/strip-backup/* | |||
|
11 | rm .hg/strip-backup/* | |||
|
12 | } | |||
8 | teststrip() { |
|
13 | teststrip() { | |
9 | hg up -C $1 |
|
14 | hg up -C $1 | |
10 | echo % before update $1, strip $2 |
|
15 | echo % before update $1, strip $2 | |
11 | hg parents |
|
16 | hg parents | |
12 | hg strip $2 | hidebackup |
|
17 | hg --traceback strip $2 | hidebackup | |
13 | echo % after update $1, strip $2 |
|
18 | echo % after update $1, strip $2 | |
14 | hg parents |
|
19 | hg parents | |
15 | hg unbundle -q .hg/strip-backup/* |
|
20 | restore | |
16 | rm .hg/strip-backup/* |
|
|||
17 | } |
|
21 | } | |
18 |
|
22 | |||
19 | hg init test |
|
23 | hg init test | |
@@ -53,6 +57,25 b' hg parents' | |||||
53 | hg strip 4 2>&1 | hidebackup |
|
57 | hg strip 4 2>&1 | hidebackup | |
54 | echo % after strip of merge parent |
|
58 | echo % after strip of merge parent | |
55 | hg parents |
|
59 | hg parents | |
|
60 | restore | |||
|
61 | ||||
|
62 | hg up | |||
|
63 | hg glog | |||
|
64 | echo % 2 is parent of 3, only one strip should happen | |||
|
65 | hg strip 2 3 | hidebackup | |||
|
66 | hg glog | |||
|
67 | restore | |||
|
68 | hg glog | |||
|
69 | echo % 2 different branches: 2 strips | |||
|
70 | hg strip 2 4 | hidebackup | |||
|
71 | hg glog | |||
|
72 | restore | |||
|
73 | echo % 2 different branches and a common ancestor: 1 strip | |||
|
74 | hg strip 1 2 4 | hidebackup | |||
|
75 | restore | |||
|
76 | ||||
|
77 | # remove branchy history for qimport tests | |||
|
78 | hg strip 3 | hidebackup | |||
56 |
|
79 | |||
57 | #strip of applied mq should cleanup status file |
|
80 | #strip of applied mq should cleanup status file | |
58 | hg up -C 3 |
|
81 | hg up -C 3 |
@@ -166,6 +166,103 b' date: Thu Jan 01 00:00:00 1970 +0' | |||||
166 | summary: b |
|
166 | summary: b | |
167 |
|
167 | |||
168 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
168 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
169 | @ changeset: 4:264128213d29 | |||
|
170 | | tag: tip | |||
|
171 | | parent: 1:ef3a871183d7 | |||
|
172 | | user: test | |||
|
173 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
174 | | summary: c | |||
|
175 | | | |||
|
176 | | o changeset: 3:443431ffac4f | |||
|
177 | | | user: test | |||
|
178 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
179 | | | summary: e | |||
|
180 | | | | |||
|
181 | | o changeset: 2:65bd5f99a4a3 | |||
|
182 | |/ user: test | |||
|
183 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
184 | | summary: d | |||
|
185 | | | |||
|
186 | o changeset: 1:ef3a871183d7 | |||
|
187 | | user: test | |||
|
188 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
189 | | summary: b | |||
|
190 | | | |||
|
191 | o changeset: 0:9ab35a2d17cb | |||
|
192 | user: test | |||
|
193 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
194 | summary: a | |||
|
195 | ||||
|
196 | % 2 is parent of 3, only one strip should happen | |||
|
197 | saved backup bundle to | |||
|
198 | @ changeset: 2:264128213d29 | |||
|
199 | | tag: tip | |||
|
200 | | user: test | |||
|
201 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
202 | | summary: c | |||
|
203 | | | |||
|
204 | o changeset: 1:ef3a871183d7 | |||
|
205 | | user: test | |||
|
206 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
207 | | summary: b | |||
|
208 | | | |||
|
209 | o changeset: 0:9ab35a2d17cb | |||
|
210 | user: test | |||
|
211 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
212 | summary: a | |||
|
213 | ||||
|
214 | o changeset: 4:443431ffac4f | |||
|
215 | | tag: tip | |||
|
216 | | user: test | |||
|
217 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
218 | | summary: e | |||
|
219 | | | |||
|
220 | o changeset: 3:65bd5f99a4a3 | |||
|
221 | | parent: 1:ef3a871183d7 | |||
|
222 | | user: test | |||
|
223 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
224 | | summary: d | |||
|
225 | | | |||
|
226 | | @ changeset: 2:264128213d29 | |||
|
227 | |/ user: test | |||
|
228 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
229 | | summary: c | |||
|
230 | | | |||
|
231 | o changeset: 1:ef3a871183d7 | |||
|
232 | | user: test | |||
|
233 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
234 | | summary: b | |||
|
235 | | | |||
|
236 | o changeset: 0:9ab35a2d17cb | |||
|
237 | user: test | |||
|
238 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
239 | summary: a | |||
|
240 | ||||
|
241 | % 2 different branches: 2 strips | |||
|
242 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
243 | saved backup bundle to | |||
|
244 | saved backup bundle to | |||
|
245 | @ changeset: 2:65bd5f99a4a3 | |||
|
246 | | tag: tip | |||
|
247 | | user: test | |||
|
248 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
249 | | summary: d | |||
|
250 | | | |||
|
251 | o changeset: 1:ef3a871183d7 | |||
|
252 | | user: test | |||
|
253 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
254 | | summary: b | |||
|
255 | | | |||
|
256 | o changeset: 0:9ab35a2d17cb | |||
|
257 | user: test | |||
|
258 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
259 | summary: a | |||
|
260 | ||||
|
261 | % 2 different branches and a common ancestor: 1 strip | |||
|
262 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
263 | saved backup bundle to | |||
|
264 | saved backup bundle to | |||
|
265 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
169 | % applied patches before strip |
|
266 | % applied patches before strip | |
170 | 2.diff |
|
267 | 2.diff | |
171 | 3.diff |
|
268 | 3.diff |
@@ -59,7 +59,7 b' list of commands:' | |||||
59 | qseries print the entire series file |
|
59 | qseries print the entire series file | |
60 | qtop print the name of the current patch |
|
60 | qtop print the name of the current patch | |
61 | qunapplied print the patches not yet applied |
|
61 | qunapplied print the patches not yet applied | |
62 |
strip strip |
|
62 | strip strip changesets and all their descendants from the repository | |
63 |
|
63 | |||
64 | use "hg -v help mq" to show aliases and global options |
|
64 | use "hg -v help mq" to show aliases and global options | |
65 | adding a |
|
65 | adding a |
General Comments 0
You need to be logged in to leave comments.
Login now