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