changeset 7620:fbfd92d51540

mq: refactor the pop code to be more readable and allow more changes
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 12 Jan 2009 09:53:55 +0100
parents e9da3de01e0a
children 6d891df43a5f
files hgext/mq.py
diffstat 1 files changed, 13 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Jan 12 09:13:45 2009 +0100
+++ b/hgext/mq.py	Mon Jan 12 09:53:55 2009 +0100
@@ -993,6 +993,17 @@
                 self.ui.warn(_("no patches applied\n"))
                 return not all
 
+            if all:
+                start = 0
+            elif patch:
+                start = info[0] + 1
+            else:
+                start = len(self.applied) - 1
+
+            if start >= len(self.applied):
+                self.ui.warn(_("qpop: %s is already at the top\n") % patch)
+                return
+
             if not update:
                 parents = repo.dirstate.parents()
                 rr = [ revlog.bin(x.rev) for x in self.applied ]
@@ -1004,23 +1015,9 @@
             if not force and update:
                 self.check_localchanges(repo)
 
-            self.applied_dirty = 1;
+            self.applied_dirty = 1
             end = len(self.applied)
-            if not patch:
-                if all:
-                    popi = 0
-                else:
-                    popi = len(self.applied) - 1
-            else:
-                popi = info[0] + 1
-                if popi >= end:
-                    self.ui.warn(_("qpop: %s is already at the top\n") % patch)
-                    return
-            info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name]
-
-            start = info[0]
-            rev = revlog.bin(info[1])
-
+            rev = revlog.bin(self.applied[start].rev)
             if update:
                 top = self.check_toppatch(repo)