# HG changeset patch # User FUJIWARA Katsunori # Date 1410456559 -32400 # Node ID 4bbcee186fc64e39c51f90e8256466885a3a4d65 # Parent c89379d47e959804e03f349ec5b3fb6b2eaf2d3b 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 -r c89379d47e95 -r 4bbcee186fc6 hgext/mq.py --- 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: diff -r c89379d47e95 -r 4bbcee186fc6 tests/test-mq-guards.t --- 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