hgext/mq.py
changeset 13373 900a92862a7b
parent 13327 dc11e30b48a3
parent 13369 69238d0ca60f
child 13400 14f3795a5ed7
--- a/hgext/mq.py	Sun Feb 13 12:19:58 2011 -0600
+++ b/hgext/mq.py	Mon Feb 14 14:12:48 2011 -0600
@@ -1061,15 +1061,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: