mq: fix qpush --move with comments in series file between applied patches stable
authorMads Kiilerich <mads@kiilerich.com>
Thu, 29 Mar 2012 00:35:00 +0200
branchstable
changeset 16303 7ee8aa662937
parent 16302 49b54f1ae053
child 16313 e785456f9631
mq: fix qpush --move with comments in series file between applied patches The 'start' variable pointed to qtip in self.series, but it was used for indexing self.fullseries. When fullseries had holes and the patch was moved to self.fullseries[start] it would end up too early in self.series and it could thus not be found in self.series[start:] and it would crash. Now the 'fullstart' index in fullseries is found used instead.
hgext/mq.py
tests/test-mq.t
--- a/hgext/mq.py	Wed Mar 28 19:24:13 2012 -0500
+++ b/hgext/mq.py	Thu Mar 29 00:35:00 2012 +0200
@@ -1200,15 +1200,19 @@
             if move:
                 if not patch:
                     raise util.Abort(_("please specify the patch to move"))
-                for i, rpn in enumerate(self.fullseries[start:]):
+                for fullstart, rpn in enumerate(self.fullseries):
+                    # strip markers for patch guards
+                    if self.guard_re.split(rpn, 1)[0] == self.series[start]:
+                        break
+                for i, rpn in enumerate(self.fullseries[fullstart:]):
                     # strip markers for patch guards
                     if self.guard_re.split(rpn, 1)[0] == patch:
                         break
-                index = start + i
+                index = fullstart + i
                 assert index < len(self.fullseries)
                 fullpatch = self.fullseries[index]
                 del self.fullseries[index]
-                self.fullseries.insert(start, fullpatch)
+                self.fullseries.insert(fullstart, fullpatch)
                 self.parseseries()
                 self.seriesdirty = True
 
--- a/tests/test-mq.t	Wed Mar 28 19:24:13 2012 -0500
+++ b/tests/test-mq.t	Thu Mar 29 00:35:00 2012 +0200
@@ -519,7 +519,15 @@
   $ hg qpush --move test.patch # already applied
   abort: cannot push to a previous patch: test.patch
   [255]
-  $ hg qpush
+  $ sed -i.bak '2i# make qtip index different in series and fullseries' `hg root`/.hg/patches/series
+  $ cat `hg root`/.hg/patches/series
+  # comment
+  # make qtip index different in series and fullseries
+  
+  test.patch
+  test1b.patch
+  test2.patch
+  $ hg qpush --move test2.patch
   applying test2.patch
   now at: test2.patch
 
@@ -527,11 +535,12 @@
 series after move
 
   $ cat `hg root`/.hg/patches/series
+  # comment
+  # make qtip index different in series and fullseries
+  
   test.patch
   test1b.patch
   test2.patch
-  # comment
-  
 
 
 pop, qapplied, qunapplied