##// END OF EJS Templates
Modify qpush/qpop idempotent operations to return success...
Ben Thomas -
r4100:c30c922f default
parent child Browse files
Show More
@@ -802,10 +802,29 b' class queue:'
802 if not wlock:
802 if not wlock:
803 wlock = repo.wlock()
803 wlock = repo.wlock()
804 patch = self.lookup(patch)
804 patch = self.lookup(patch)
805 if patch and self.isapplied(patch):
805 # Suppose our series file is: A B C and the current 'top' patch is B.
806 raise util.Abort(_("patch %s is already applied") % patch)
806 # qpush C should be performed (moving forward)
807 # qpush B is a NOP (no change)
808 # qpush A is an error (can't go backwards with qpush)
809 if patch:
810 info = self.isapplied(patch)
811 if info:
812 if info[0] < len(self.applied) - 1:
813 raise util.Abort(_("cannot push to a previous patch: %s") %
814 patch)
815 if info[0] < len(self.series) - 1:
816 self.ui.warn(_('qpush: %s is already at the top\n') % patch)
817 else:
818 self.ui.warn(_('all patches are currently applied\n'))
819 return
820
821 # Following the above example, starting at 'top' of B:
822 # qpush should be performed (pushes C), but a subsequent qpush without
823 # an argument is an error (nothing to apply). This allows a loop
824 # of "...while hg qpush..." to work as it detects an error when done
807 if self.series_end() == len(self.series):
825 if self.series_end() == len(self.series):
808 raise util.Abort(_("patch series fully applied"))
826 self.ui.warn(_('patch series already fully applied\n'))
827 return 1
809 if not force:
828 if not force:
810 self.check_localchanges(repo)
829 self.check_localchanges(repo)
811
830
@@ -847,8 +866,12 b' class queue:'
847 info = self.isapplied(patch)
866 info = self.isapplied(patch)
848 if not info:
867 if not info:
849 raise util.Abort(_("patch %s is not applied") % patch)
868 raise util.Abort(_("patch %s is not applied") % patch)
869
850 if len(self.applied) == 0:
870 if len(self.applied) == 0:
851 raise util.Abort(_("no patches applied"))
871 # Allow qpop -a to work repeatedly,
872 # but not qpop without an argument
873 self.ui.warn(_("no patches applied\n"))
874 return not all
852
875
853 if not update:
876 if not update:
854 parents = repo.dirstate.parents()
877 parents = repo.dirstate.parents()
@@ -1766,7 +1789,8 b' def push(ui, repo, patch=None, **opts):'
1766
1789
1767 if opts['all']:
1790 if opts['all']:
1768 if not q.series:
1791 if not q.series:
1769 raise util.Abort(_('no patches in series'))
1792 ui.warn(_('no patches in series\n'))
1793 return 0
1770 patch = q.series[-1]
1794 patch = q.series[-1]
1771 if opts['merge']:
1795 if opts['merge']:
1772 if opts['name']:
1796 if opts['name']:
General Comments 0
You need to be logged in to leave comments. Login now