[PATCH 4 of 4 STABLE] mq: examine "pushable" of already applied patch correctly

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Sep 11 12:48:44 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1410456559 -32400
#      Fri Sep 12 02:29:19 2014 +0900
# Branch stable
# Node ID 524f1008c062747fd6501ca7e05fa817d9776b8d
# Parent  d73ceeacc825f29ac22d7a7d80113e7779ad3117
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]".

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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:
diff --git a/tests/test-mq-guards.t b/tests/test-mq-guards.t
--- a/tests/test-mq-guards.t
+++ b/tests/test-mq-guards.t
@@ -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


More information about the Mercurial-devel mailing list