hgext/mq.py
branchstable
changeset 13369 69238d0ca60f
parent 13224 0a1eefaf98f2
child 13373 900a92862a7b
--- a/hgext/mq.py	Thu Feb 03 00:27:44 2011 -0600
+++ b/hgext/mq.py	Sat Feb 12 16:08:41 2011 +0800
@@ -1029,15 +1029,17 @@
             # go backwards with qpush)
             if patch:
                 info = self.isapplied(patch)
-                if info:
-                    if info[0] < len(self.applied) - 1:
-                        raise util.Abort(
-                            _("cannot push to a previous patch: %s") % patch)
+                if info and info[0] >= len(self.applied) - 1:
                     self.ui.warn(
                         _('qpush: %s is already at the top\n') % patch)
                     return 0
+
                 pushable, reason = self.pushable(patch)
-                if not pushable:
+                if pushable:
+                    if self.series.index(patch) < self.series_end():
+                        raise util.Abort(
+                            _("cannot push to a previous patch: %s") % patch)
+                else:
                     if reason:
                         reason = _('guarded by %r') % reason
                     else: