Mercurial > hg
changeset 22457:48791c2bea1c
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 16 Sep 2014 14:49:56 -0500 |
parents | 75e166b82c7a (current diff) 4bbcee186fc6 (diff) |
children | a476ee0b8e79 |
files | hgext/mq.py |
diffstat | 3 files changed, 94 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri Aug 29 05:09:59 2014 +0200 +++ b/hgext/mq.py Tue Sep 16 14:49:56 2014 -0500 @@ -2992,18 +2992,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') % @@ -3039,18 +3038,17 @@ 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)): - pushable, reason = q.pushable(i) - if not pushable: + if not pushable(i): ui.status(_('popping guarded patches\n')) popped = True 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:
--- a/tests/test-mq-guards.t Fri Aug 29 05:09:59 2014 +0200 +++ b/tests/test-mq-guards.t Tue Sep 16 14:49:56 2014 -0500 @@ -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 + 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 @@ -388,7 +395,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 +513,78 @@ 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 + +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 + +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
--- a/tests/test-mq-qpush-fail.t Fri Aug 29 05:09:59 2014 +0200 +++ b/tests/test-mq-qpush-fail.t Tue Sep 16 14:49:56 2014 -0500 @@ -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]