changeset 22453:fd0f0b0d316d stable

mq: report correct numbers for changing "number of guarded, applied patches" Before this patch, "hg qselect" may report incorrect numbers for "number of guarded, applied patches has changed", because it examines "pushable" of patches by the index not in "the series" but in "applied patches", even though "mq.pushable()" expects the former. To report correct numbers for changing "number of guarded, applied patches", this patch uses the name of applied patch to examine pushable-ness of it. This patch also changes the result of existing "hg qselect" tests, because they doesn't change pushable-ness of already applied patches. This patch assumes that "hg qselect" focuses on changing pushable-ness only of already applied patches, because: - the report message uses not "previous" (in the series) but "applied" - the logic to pop patches for --pop/--reapply examines pushable-ness only of already applied ones (in fact, there are some incorrect code paths)
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 12 Sep 2014 02:29:19 +0900
parents f98abe3146b2
children ac31d87608d6
files hgext/mq.py tests/test-mq-guards.t tests/test-mq-qpush-fail.t
diffstat 3 files changed, 36 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Sep 10 00:41:44 2014 +0900
+++ b/hgext/mq.py	Fri Sep 12 02:29:19 2014 +0900
@@ -2969,18 +2969,17 @@
 
     q = repo.mq
     guards = q.active()
+    pushable = lambda i: q.pushable(q.applied[i].name)[0]
     if args or opts.get('none'):
         old_unapplied = q.unapplied(repo)
-        old_guarded = [i for i in xrange(len(q.applied)) if
-                       not q.pushable(i)[0]]
+        old_guarded = [i for i in xrange(len(q.applied)) if not pushable(i)]
         q.setactive(args)
         q.savedirty()
         if not args:
             ui.status(_('guards deactivated\n'))
         if not opts.get('pop') and not opts.get('reapply'):
             unapplied = q.unapplied(repo)
-            guarded = [i for i in xrange(len(q.applied))
-                       if not q.pushable(i)[0]]
+            guarded = [i for i in xrange(len(q.applied)) if not pushable(i)]
             if len(unapplied) != len(old_unapplied):
                 ui.status(_('number of unguarded, unapplied patches has '
                             'changed from %d to %d\n') %
--- a/tests/test-mq-guards.t	Wed Sep 10 00:41:44 2014 +0900
+++ b/tests/test-mq-guards.t	Fri Sep 12 02:29:19 2014 +0900
@@ -388,7 +388,6 @@
   3 G d.patch
   $ hg qselect 2
   number of unguarded, unapplied patches has changed from 0 to 1
-  number of guarded, applied patches has changed from 1 to 0
   $ qappunappv
   % hg qapplied
   new.patch
@@ -507,3 +506,31 @@
   0 G new.patch
   1 A c.patch
   2 A d.patch
+
+test that qselect shows "number of guarded, applied patches" correctly
+
+  $ hg qimport -q -e b.patch
+  adding b.patch to series file
+  $ hg qguard -- b.patch -not-b
+  $ hg qpop -a -q
+  patch queue now empty
+  $ hg qunapplied -v
+  0 G new.patch
+  1 U c.patch
+  2 U d.patch
+  3 U b.patch
+  $ hg qselect not-new not-c
+  number of unguarded, unapplied patches has changed from 3 to 2
+  $ hg qpush -q -a
+  patch d.patch is empty
+  now at: b.patch
+
+  $ hg qapplied -v
+  0 G new.patch
+  1 G c.patch
+  2 A d.patch
+  3 A b.patch
+  $ hg qselect --none
+  guards deactivated
+  $ hg qselect not-new not-c not-d
+  number of guarded, applied patches has changed from 0 to 1
--- a/tests/test-mq-qpush-fail.t	Wed Sep 10 00:41:44 2014 +0900
+++ b/tests/test-mq-qpush-fail.t	Fri Sep 12 02:29:19 2014 +0900
@@ -131,8 +131,12 @@
   now at: c
 
 now try it when a is unguarded, and we're at the top of the queue
+
+  $ hg qapplied -v
+  0 G a
+  1 A b
+  2 A c
   $ hg qsel block
-  number of guarded, applied patches has changed from 1 to 0
   $ hg qpush b
   abort: cannot push to a previous patch: b
   [255]