Show More
@@ -535,6 +535,41 b' class queue:' | |||
|
535 | 535 | break |
|
536 | 536 | return (err, n) |
|
537 | 537 | |
|
538 | def _clean_series(self, patches): | |
|
539 | indices = [self.find_series(p) for p in patches] | |
|
540 | indices.sort() | |
|
541 | for i in indices[-1::-1]: | |
|
542 | del self.full_series[i] | |
|
543 | self.parse_series() | |
|
544 | self.series_dirty = 1 | |
|
545 | ||
|
546 | def finish(self, repo, revs): | |
|
547 | revs.sort() | |
|
548 | firstrev = repo.changelog.rev(revlog.bin(self.applied[0].rev)) | |
|
549 | appliedbase = 0 | |
|
550 | patches = [] | |
|
551 | for rev in revs: | |
|
552 | if rev < firstrev: | |
|
553 | raise util.Abort(_('revision %d is not managed') % rev) | |
|
554 | base = revlog.bin(self.applied[appliedbase].rev) | |
|
555 | node = repo.changelog.node(rev) | |
|
556 | if node != base: | |
|
557 | raise util.Abort(_('cannot delete revision %d above ' | |
|
558 | 'applied patches') % rev) | |
|
559 | patches.append(self.applied[appliedbase].name) | |
|
560 | appliedbase += 1 | |
|
561 | ||
|
562 | r = self.qrepo() | |
|
563 | if r: | |
|
564 | r.remove(patches, True) | |
|
565 | else: | |
|
566 | for p in patches: | |
|
567 | os.unlink(self.join(p)) | |
|
568 | ||
|
569 | del self.applied[:appliedbase] | |
|
570 | self.applied_dirty = 1 | |
|
571 | self._clean_series(patches) | |
|
572 | ||
|
538 | 573 | def delete(self, repo, patches, opts): |
|
539 | 574 | if not patches and not opts.get('rev'): |
|
540 | 575 | raise util.Abort(_('qdelete requires at least one revision or ' |
@@ -580,12 +615,7 b' class queue:' | |||
|
580 | 615 | if appliedbase: |
|
581 | 616 | del self.applied[:appliedbase] |
|
582 | 617 | self.applied_dirty = 1 |
|
583 |
|
|
|
584 | indices.sort() | |
|
585 | for i in indices[-1::-1]: | |
|
586 | del self.full_series[i] | |
|
587 | self.parse_series() | |
|
588 | self.series_dirty = 1 | |
|
618 | self._clean_series(realpatches) | |
|
589 | 619 | |
|
590 | 620 | def check_toppatch(self, repo): |
|
591 | 621 | if len(self.applied) > 0: |
@@ -1497,9 +1527,8 b' def delete(ui, repo, *patches, **opts):' | |||
|
1497 | 1527 | the --rev parameter. At least one patch or revision is required. |
|
1498 | 1528 | |
|
1499 | 1529 | With --rev, mq will stop managing the named revisions (converting |
|
1500 |
them to regular mercurial changesets). The |
|
|
1501 | and at the base of the stack. This option is useful when the patches | |
|
1502 | have been applied upstream. | |
|
1530 | them to regular mercurial changesets). The qfinish command should be | |
|
1531 | used as an alternative for qdel -r, as the latter option is deprecated. | |
|
1503 | 1532 | |
|
1504 | 1533 | With --keep, the patch files are preserved in the patch directory.""" |
|
1505 | 1534 | q = repo.mq |
@@ -2185,6 +2214,34 b' def select(ui, repo, *args, **opts):' | |||
|
2185 | 2214 | finally: |
|
2186 | 2215 | q.save_dirty() |
|
2187 | 2216 | |
|
2217 | def finish(ui, repo, *revrange, **opts): | |
|
2218 | """move applied patches into repository history | |
|
2219 | ||
|
2220 | Finishes the specified revisions (corresponding to applied patches) by | |
|
2221 | moving them out of mq control into regular repository history. | |
|
2222 | ||
|
2223 | Accepts a revision range or the --all option. If --all is specified, all | |
|
2224 | applied mq revisions are removed from mq control. Otherwise, the given | |
|
2225 | revisions must be at the base of the stack of applied patches. | |
|
2226 | ||
|
2227 | This can be especially useful if your changes have been applied to an | |
|
2228 | upstream repository, or if you are about to push your changes to upstream. | |
|
2229 | """ | |
|
2230 | if not opts['applied'] and not revrange: | |
|
2231 | raise util.Abort(_('no revisions specified')) | |
|
2232 | elif opts['applied']: | |
|
2233 | revrange = ('qbase:qtip',) + revrange | |
|
2234 | ||
|
2235 | q = repo.mq | |
|
2236 | if not q.applied: | |
|
2237 | ui.status(_('no patches applied\n')) | |
|
2238 | return 0 | |
|
2239 | ||
|
2240 | revs = cmdutil.revrange(repo, revrange) | |
|
2241 | q.finish(repo, revs) | |
|
2242 | q.save_dirty() | |
|
2243 | return 0 | |
|
2244 | ||
|
2188 | 2245 | def reposetup(ui, repo): |
|
2189 | 2246 | class mqrepo(repo.__class__): |
|
2190 | 2247 | def abort_if_wdir_patched(self, errmsg, force=False): |
@@ -2395,4 +2452,8 b' cmdtable = {' | |||
|
2395 | 2452 | _('hg strip [-f] [-b] [-n] REV')), |
|
2396 | 2453 | "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
|
2397 | 2454 | "qunapplied": (unapplied, [] + seriesopts, _('hg qunapplied [-s] [PATCH]')), |
|
2455 | "qfinish": | |
|
2456 | (finish, | |
|
2457 | [('a', 'applied', None, _('finish all applied changesets'))], | |
|
2458 | _('hg qfinish [-a] [REV...]')), | |
|
2398 | 2459 | } |
@@ -35,3 +35,33 b' hg qdel -r e' | |||
|
35 | 35 | hg qdel -r qbase:e |
|
36 | 36 | hg qapplied |
|
37 | 37 | hg log --template '{rev} {desc}\n' |
|
38 | ||
|
39 | cd .. | |
|
40 | hg init b | |
|
41 | cd b | |
|
42 | ||
|
43 | echo 'base' > base | |
|
44 | hg ci -Ambase | |
|
45 | ||
|
46 | hg qfinish | |
|
47 | hg qfinish -a | |
|
48 | ||
|
49 | hg qnew a | |
|
50 | hg qnew b | |
|
51 | hg qnew c | |
|
52 | ||
|
53 | hg qfinish 0 | |
|
54 | hg qfinish b | |
|
55 | ||
|
56 | hg qpop | |
|
57 | hg qfinish -a c | |
|
58 | hg qpush | |
|
59 | ||
|
60 | hg qfinish qbase:b | |
|
61 | hg qapplied | |
|
62 | hg log --template '{rev} {desc}\n' | |
|
63 | ||
|
64 | hg qfinish -a c | |
|
65 | hg qapplied | |
|
66 | hg log --template '{rev} {desc}\n' | |
|
67 | ls .hg/patches |
@@ -22,3 +22,23 b' 3 [mq]: e' | |||
|
22 | 22 | 2 [mq]: d |
|
23 | 23 | 1 [mq]: a |
|
24 | 24 | 0 base |
|
25 | adding base | |
|
26 | abort: no revisions specified | |
|
27 | no patches applied | |
|
28 | abort: revision 0 is not managed | |
|
29 | abort: cannot delete revision 2 above applied patches | |
|
30 | Now at: b | |
|
31 | abort: unknown revision 'c'! | |
|
32 | applying c | |
|
33 | Now at: c | |
|
34 | c | |
|
35 | 3 imported patch c | |
|
36 | 2 [mq]: b | |
|
37 | 1 [mq]: a | |
|
38 | 0 base | |
|
39 | 3 imported patch c | |
|
40 | 2 [mq]: b | |
|
41 | 1 [mq]: a | |
|
42 | 0 base | |
|
43 | series | |
|
44 | status |
@@ -29,6 +29,7 b' list of commands:' | |||
|
29 | 29 | qcommit commit changes in the queue repository |
|
30 | 30 | qdelete remove patches from queue |
|
31 | 31 | qdiff diff of the current patch and subsequent modifications |
|
32 | qfinish move applied patches into repository history | |
|
32 | 33 | qfold fold the named patches into the current patch |
|
33 | 34 | qgoto push or pop patches until named patch is at top of stack |
|
34 | 35 | qguard set or print guards for a patch |
General Comments 0
You need to be logged in to leave comments.
Login now