mq: examine "pushable" of already applied patch correctly stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 12 Sep 2014 02:29:19 +0900
branchstable
changeset 22456 4bbcee186fc6
parent 22455 c89379d47e95
child 22457 48791c2bea1c
child 22492 d5261db0011f
child 22598 bcb8195e772a
mq: examine "pushable" of already applied patch correctly Before this patch, "hg qselect" with --pop/--reapply may pop patches unexpectedly, even when all of patches applied before "qselect" are still pushable. Strictly speaking about the condition of this issue: - before "qselect" - there are N applied patches - the index of the guarded patch X in the series is less than N - after "qselect" - X is still guarded, and - all of applied patched are still pushable In the case above, "hg qselect" should keep current status, but it actually tries to pop patches because of X. The index in "the series" should be used to examine "pushable" of a patch by "mq.pushablek()", but the index in "applied patches" is used, and this may cause unexpected examination of guarded patch. To examine "pushable" of already applied patch correctly, this patch uses "mq.applied[i].name": "pushable" is the function introduced by the previous patch, and it returns "mq.pushable(mq.applied[i].name)[0]".
hgext/mq.py
tests/test-mq-guards.t
--- a/hgext/mq.py	Fri Sep 12 02:29:19 2014 +0900
+++ b/hgext/mq.py	Fri Sep 12 02:29:19 2014 +0900
@@ -3019,8 +3019,7 @@
     popped = False
     if opts.get('pop') or opts.get('reapply'):
         for i in xrange(len(q.applied)):
-            pushable, reason = q.pushable(i)
-            if not pushable:
+            if not pushable(i):
                 ui.status(_('popping guarded patches\n'))
                 popped = True
                 if i == 0:
--- a/tests/test-mq-guards.t	Fri Sep 12 02:29:19 2014 +0900
+++ b/tests/test-mq-guards.t	Fri Sep 12 02:29:19 2014 +0900
@@ -566,3 +566,25 @@
   1 G c.patch
   2 A d.patch
   3 G b.patch
+
+test that "qselect --reapply" checks applied patches correctly when no
+applied patche becomes guarded but some of unapplied ones become
+unguarded.
+
+  $ hg qpop -q -a
+  patch queue now empty
+  $ hg qselect not-new not-c not-d
+  number of unguarded, unapplied patches has changed from 2 to 1
+  $ hg qpush -q -a
+  now at: b.patch
+  $ hg qapplied -v
+  0 G new.patch
+  1 G c.patch
+  2 G d.patch
+  3 A b.patch
+  $ hg qselect -q --reapply not-new not-c
+  $ hg qseries -v
+  0 G new.patch
+  1 G c.patch
+  2 U d.patch
+  3 A b.patch