mq: qpop should act like quilt pop
authorChris Mason <mason@suse.com>
Thu, 27 Jul 2006 09:27:39 -0700
changeset 2697 6c540dd14c38
parent 2696 be273f6074de
child 2698 c1123e83c8e2
mq: qpop should act like quilt pop qpop patchname would pop the named patch off the stack. This is slightly different from how quilt pop works. quilt pop pops everything up to the named patch.
hgext/mq.py
--- a/hgext/mq.py	Thu Jul 27 09:27:35 2006 -0700
+++ b/hgext/mq.py	Thu Jul 27 09:27:39 2006 -0700
@@ -708,7 +708,8 @@
             self.ui.write("Now at: %s\n" % top)
         return ret[0]
 
-    def pop(self, repo, patch=None, force=False, update=True, wlock=None):
+    def pop(self, repo, patch=None, force=False, update=True, all=False,
+            wlock=None):
         def getfile(f, rev):
             t = repo.file(f).read(rev)
             try:
@@ -749,7 +750,17 @@
         self.applied_dirty = 1;
         end = len(self.applied)
         if not patch:
-            info = [len(self.applied) - 1] + self.applied[-1].split(':')
+            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].split(':')
+
         start = info[0]
         rev = revlog.bin(info[1])
 
@@ -1276,9 +1287,7 @@
         localupdate = False
     else:
         q = repomap[repo]
-    if opts['all'] and len(q.applied) > 0:
-        patch = q.applied[0].split(':')[1]
-    q.pop(repo, patch, force=opts['force'], update=localupdate)
+    q.pop(repo, patch, force=opts['force'], update=localupdate, all=opts['all'])
     q.save_dirty()
     return 0