##// END OF EJS Templates
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully -
r7398:2cd1308c default
parent child Browse files
Show More
@@ -824,11 +824,15 b' class queue:'
824 824 raise util.Abort(_("patch %s not in series") % patch)
825 825
826 826 def push(self, repo, patch=None, force=False, list=False,
827 mergeq=None):
827 mergeq=None, all=False):
828 828 wlock = repo.wlock()
829 829 if repo.dirstate.parents()[0] != repo.changelog.tip():
830 830 self.ui.status(_("(working directory not at tip)\n"))
831 831
832 if not self.series:
833 self.ui.warn(_('no patches in series\n'))
834 return 0
835
832 836 try:
833 837 patch = self.lookup(patch)
834 838 # Suppose our series file is: A B C and the current 'top'
@@ -841,26 +845,36 b' class queue:'
841 845 if info[0] < len(self.applied) - 1:
842 846 raise util.Abort(
843 847 _("cannot push to a previous patch: %s") % patch)
844 if info[0] < len(self.series) - 1:
845 self.ui.warn(
846 _('qpush: %s is already at the top\n') % patch)
848 self.ui.warn(
849 _('qpush: %s is already at the top\n') % patch)
850 return
851 pushable, reason = self.pushable(patch)
852 if not pushable:
853 if reason:
854 reason = _('guarded by %r') % reason
847 855 else:
848 self.ui.warn(_('all patches are currently applied\n'))
849 return
856 reason = _('no matching guards')
857 self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason))
858 return 1
859 elif all:
860 patch = self.series[-1]
861 if self.isapplied(patch):
862 self.ui.warn(_('all patches are currently applied\n'))
863 return 0
850 864
851 865 # Following the above example, starting at 'top' of B:
852 866 # qpush should be performed (pushes C), but a subsequent
853 867 # qpush without an argument is an error (nothing to
854 868 # apply). This allows a loop of "...while hg qpush..." to
855 869 # work as it detects an error when done
856 if self.series_end() == len(self.series):
870 start = self.series_end()
871 if start == len(self.series):
857 872 self.ui.warn(_('patch series already fully applied\n'))
858 873 return 1
859 874 if not force:
860 875 self.check_localchanges(repo)
861 876
862 self.applied_dirty = 1;
863 start = self.series_end()
877 self.applied_dirty = 1
864 878 if start > 0:
865 879 self.check_toppatch(repo)
866 880 if not patch:
@@ -2000,11 +2014,6 b' def push(ui, repo, patch=None, **opts):'
2000 2014 q = repo.mq
2001 2015 mergeq = None
2002 2016
2003 if opts['all']:
2004 if not q.series:
2005 ui.warn(_('no patches in series\n'))
2006 return 0
2007 patch = q.series[-1]
2008 2017 if opts['merge']:
2009 2018 if opts['name']:
2010 2019 newpath = repo.join(opts['name'])
@@ -2016,7 +2025,7 b' def push(ui, repo, patch=None, **opts):'
2016 2025 mergeq = queue(ui, repo.join(""), newpath)
2017 2026 ui.warn(_("merging with queue at: %s\n") % mergeq.path)
2018 2027 ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
2019 mergeq=mergeq)
2028 mergeq=mergeq, all=opts.get('all'))
2020 2029 return ret
2021 2030
2022 2031 def pop(ui, repo, patch=None, **opts):
@@ -39,6 +39,9 b' echo % should print +a'
39 39 hg qguard
40 40 hg qpop
41 41
42 echo % should fail
43 hg qpush a.patch
44
42 45 hg qguard a.patch
43 46 echo % should push b.patch
44 47 hg qpush
@@ -10,6 +10,8 b' Now at: a.patch'
10 10 % should print +a
11 11 a.patch: +a
12 12 Patch queue now empty
13 % should fail
14 cannot push 'a.patch' - guarded by ['+a']
13 15 a.patch: +a
14 16 % should push b.patch
15 17 applying b.patch
@@ -227,7 +227,7 b' all patches are currently applied'
227 227 patch series already fully applied
228 228 qpush fails
229 229 % does nothing and succeeds
230 all patches are currently applied
230 qpush: test2.patch is already at the top
231 231 qpush test2.patch succeeds
232 232 % strip
233 233 adding x
General Comments 0
You need to be logged in to leave comments. Login now