# HG changeset patch # User FUJIWARA Katsunori # Date 1410456559 -32400 # Node ID c89379d47e959804e03f349ec5b3fb6b2eaf2d3b # Parent ac31d87608d63de58682b0fed4e4fb5b9fde5918 mq: pop correct patches when changing pushable-ness of already applied ones Before this patch, "hg qselect" with --pop/--reapply may pop incorrect patches, because the index in "applied patches" is used to pop patches by "mq.pop()", even though the index in "the series" should be used. For example, when the already applied patch becomes guarded and it follows the already guarded (= not yet applied) one, "hg qselect" is aborted, because it tries to pop to guarded one. This patch uses "mq.applied[i - 1].name" to pop to the patch, of which the index in the "applied ones" is "i - 1". diff -r ac31d87608d6 -r c89379d47e95 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 @@ -3026,7 +3026,7 @@ if i == 0: q.pop(repo, all=True) else: - q.pop(repo, str(i - 1)) + q.pop(repo, q.applied[i - 1].name) break if popped: try: diff -r ac31d87608d6 -r c89379d47e95 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 @@ -541,3 +541,28 @@ guards deactivated $ hg qselect not-new not-c not-d number of guarded, applied patches has changed from 0 to 1 + +test that "qselect --reapply" reapplies patches successfully when the +already applied patch becomes unguarded and it follows the already +guarded (= not yet applied) one. + + $ hg qpop -q -a + patch queue now empty + $ hg qselect not-new not-c + number of unguarded, unapplied patches has changed from 1 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 -q --reapply not-c not-b + now at: d.patch + cannot push 'b.patch' - guarded by '-not-b' + $ hg qseries -v + 0 U new.patch + 1 G c.patch + 2 A d.patch + 3 G b.patch