Show More
@@ -616,47 +616,51 b' class queue(object):' | |||
|
616 | 616 | break |
|
617 | 617 | return (err, n) |
|
618 | 618 | |
|
619 |
def _clean |
|
|
619 | def _cleanup(self, patches, numrevs, keep=False): | |
|
620 | if not keep: | |
|
621 | r = self.qrepo() | |
|
622 | if r: | |
|
623 | r.remove(patches, True) | |
|
624 | else: | |
|
625 | for p in patches: | |
|
626 | os.unlink(self.join(p)) | |
|
627 | ||
|
628 | if numrevs: | |
|
629 | del self.applied[:numrevs] | |
|
630 | self.applied_dirty = 1 | |
|
631 | ||
|
620 | 632 | for i in sorted([self.find_series(p) for p in patches], reverse=True): |
|
621 | 633 | del self.full_series[i] |
|
622 | 634 | self.parse_series() |
|
623 | 635 | self.series_dirty = 1 |
|
624 | 636 | |
|
625 |
def |
|
|
637 | def _revpatches(self, repo, revs): | |
|
626 | 638 | firstrev = repo[self.applied[0].rev].rev() |
|
627 | appliedbase = 0 | |
|
628 | 639 | patches = [] |
|
629 |
for rev in |
|
|
640 | for i, rev in enumerate(revs): | |
|
630 | 641 | |
|
631 | 642 | if rev < firstrev: |
|
632 | 643 | raise util.Abort(_('revision %d is not managed') % rev) |
|
633 | base = bin(self.applied[appliedbase].rev) | |
|
634 | 644 | |
|
635 | 645 | ctx = repo[rev] |
|
646 | base = bin(self.applied[i].rev) | |
|
636 | 647 | if ctx.node() != base: |
|
637 | 648 | msg = _('cannot delete revision %d above applied patches') |
|
638 | 649 | raise util.Abort(msg % rev) |
|
639 | 650 | |
|
640 |
patch = self.applied[ |
|
|
651 | patch = self.applied[i].name | |
|
641 | 652 | for fmt in ('[mq]: %s', 'imported patch %s'): |
|
642 | 653 | if ctx.description() == fmt % patch: |
|
643 | 654 | msg = _('patch %s finalized without changeset message\n') |
|
644 | 655 | repo.ui.status(msg % patch) |
|
645 | 656 | break |
|
646 | 657 | |
|
647 |
patches.append( |
|
|
648 | appliedbase += 1 | |
|
658 | patches.append(patch) | |
|
659 | return patches | |
|
649 | 660 | |
|
650 | r = self.qrepo() | |
|
651 | if r: | |
|
652 | r.remove(patches, True) | |
|
653 | else: | |
|
654 | for p in patches: | |
|
655 | os.unlink(self.join(p)) | |
|
656 | ||
|
657 | del self.applied[:appliedbase] | |
|
658 | self.applied_dirty = 1 | |
|
659 | self._clean_series(patches) | |
|
661 | def finish(self, repo, revs): | |
|
662 | patches = self._revpatches(repo, sorted(revs)) | |
|
663 | self._cleanup(patches, len(patches)) | |
|
660 | 664 | |
|
661 | 665 | def delete(self, repo, patches, opts): |
|
662 | 666 | if not patches and not opts.get('rev'): |
@@ -673,37 +677,18 b' class queue(object):' | |||
|
673 | 677 | raise util.Abort(_("patch %s not in series file") % patch) |
|
674 | 678 | realpatches.append(patch) |
|
675 | 679 | |
|
676 |
|
|
|
680 | numrevs = 0 | |
|
677 | 681 | if opts.get('rev'): |
|
678 | 682 | if not self.applied: |
|
679 | 683 | raise util.Abort(_('no patches applied')) |
|
680 | 684 | revs = cmdutil.revrange(repo, opts['rev']) |
|
681 | 685 | if len(revs) > 1 and revs[0] > revs[1]: |
|
682 | 686 | revs.reverse() |
|
683 | for rev in revs: | |
|
684 | if appliedbase >= len(self.applied): | |
|
685 | raise util.Abort(_("revision %d is not managed") % rev) | |
|
686 | ||
|
687 | base = bin(self.applied[appliedbase].rev) | |
|
688 | node = repo.changelog.node(rev) | |
|
689 | if node != base: | |
|
690 | raise util.Abort(_("cannot delete revision %d above " | |
|
691 | "applied patches") % rev) | |
|
692 | realpatches.append(self.applied[appliedbase].name) | |
|
693 | appliedbase += 1 | |
|
687 | revpatches = self._revpatches(repo, revs) | |
|
688 | realpatches += revpatches | |
|
689 | numrevs = len(revpatches) | |
|
694 | 690 | |
|
695 |
|
|
|
696 | r = self.qrepo() | |
|
697 | if r: | |
|
698 | r.remove(realpatches, True) | |
|
699 | else: | |
|
700 | for p in realpatches: | |
|
701 | os.unlink(self.join(p)) | |
|
702 | ||
|
703 | if appliedbase: | |
|
704 | del self.applied[:appliedbase] | |
|
705 | self.applied_dirty = 1 | |
|
706 | self._clean_series(realpatches) | |
|
691 | self._cleanup(realpatches, numrevs, opts.get('keep')) | |
|
707 | 692 | |
|
708 | 693 | def check_toppatch(self, repo): |
|
709 | 694 | if len(self.applied) > 0: |
@@ -15,6 +15,8 b' bar' | |||
|
15 | 15 | 430ed4828a74fa4047bc816a25500f7472ab4bfe:foo |
|
16 | 16 | % |
|
17 | 17 | foo |
|
18 | patch foo finalized without changeset message | |
|
19 | patch bar finalized without changeset message | |
|
18 | 20 | %%% |
|
19 | 21 | 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c foo |
|
20 | 22 | 430ed4828a74fa4047bc816a25500f7472ab4bfe bar |
@@ -13,9 +13,12 b' a' | |||
|
13 | 13 | b |
|
14 | 14 | series |
|
15 | 15 | status |
|
16 | patch a finalized without changeset message | |
|
16 | 17 | 1 [mq]: a |
|
17 | 18 | 0 base |
|
18 | 19 | abort: cannot delete revision 3 above applied patches |
|
20 | patch d finalized without changeset message | |
|
21 | patch e finalized without changeset message | |
|
19 | 22 | f |
|
20 | 23 | 4 [mq]: f |
|
21 | 24 | 3 [mq]: e |
General Comments 0
You need to be logged in to leave comments.
Login now