[PATCH 2 of 4 STABLE] mq: use "mq.applied[i].name" instead of "mq.appliedname(i)" for safety

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Sep 11 12:48:42 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 feb907fe8902ff408380741674602a845107d844
# Parent  c3c55db74344b03f4d314361bced15067144d0a5
mq: use "mq.applied[i].name" instead of "mq.appliedname(i)" for safety

Before this patch, "hg qselect --reapply" is aborted when "--verbose"
is specified, because "mq.appliedname()" returns "INDEX PATCHNAME"
instead of "PATCHNAME" in such case and "mq.push" can't accept the
former as the name of patch.

This patch uses "mq.applied[i].name" instead of "mq.appliedname(i)" as
the name of the patch to be pushed for safety.

Now, there is no code path using "mq.appliedname()", and it should be
removed to prevent developers from using it in the wrong way like this
issue.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3015,7 +3015,7 @@
                 ui.write(g, '\n')
         else:
             ui.write(_('no active guards\n'))
-    reapply = opts.get('reapply') and q.applied and q.appliedname(-1)
+    reapply = opts.get('reapply') and q.applied and q.applied[-1].name
     popped = False
     if opts.get('pop') or opts.get('reapply'):
         for i in xrange(len(q.applied)):
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
@@ -256,14 +256,21 @@
   $ hg qpush -a
   applying c.patch
   now at: c.patch
-  $ hg qselect -n --reapply
+  $ hg qselect -n --reapply -v
   guards deactivated
   popping guarded patches
   popping c.patch
   popping b.patch
   patch queue now empty
   reapplying unguarded patches
-  applying c.patch
+  skipping a.patch - guarded by '+1' '+2'
+  skipping b.patch - guarded by '+2'
+  skipping a.patch - guarded by '+1' '+2'
+  skipping b.patch - guarded by '+2'
+  applying c.patch
+  patching file c
+  adding c
+  c
   now at: c.patch
 
 guards in series file: +1 +2 -3


More information about the Mercurial-devel mailing list