# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1281003953 -7200 # Node ID 1c00577b029839e22116e6bd5304958e96aef29a # Parent d12fe809e1ee4b341f8f2927db416c3f0142cf22 qguard: label patch names by status when listing guards diff -r d12fe809e1ee -r 1c00577b0298 hgext/mq.py --- a/hgext/mq.py Wed Aug 11 20:16:22 2010 +0800 +++ b/hgext/mq.py Thu Aug 05 12:25:53 2010 +0200 @@ -2172,7 +2172,15 @@ ''' def status(idx): guards = q.series_guards[idx] or ['unguarded'] - ui.write('%s: ' % ui.label(q.series[idx], 'qguard.patch')) + if q.series[idx] in applied: + state = 'applied' + elif q.pushable(idx)[0]: + state = 'unapplied' + else: + state = 'guarded' + label = 'qguard.patch qguard.%s qseries.%s' % (state, state) + ui.write('%s: ' % ui.label(q.series[idx], label)) + for i, guard in enumerate(guards): if guard.startswith('+'): ui.write(guard, label='qguard.positive') @@ -2184,6 +2192,7 @@ ui.write(' ') ui.write('\n') q = repo.mq + applied = set(p.name for p in q.applied) patch = None args = list(args) if opts['list']: diff -r d12fe809e1ee -r 1c00577b0298 tests/test-mq-guards --- a/tests/test-mq-guards Wed Aug 11 20:16:22 2010 +0800 +++ b/tests/test-mq-guards Thu Aug 05 12:25:53 2010 +0200 @@ -97,11 +97,16 @@ hg qguard -- a.patch +1 +2 -3 hg qselect 1 2 3 + echo % list patches and guards hg qguard -l +echo % have at least one patch applied to test coloring +hg qpush echo % list patches and guards with color hg --config extensions.color= qguard --config color.mode=ansi \ -l --color=always +echo % should pop b.patch +hg qpop echo % list series hg qseries -v echo % list guards diff -r d12fe809e1ee -r 1c00577b0298 tests/test-mq-guards.out --- a/tests/test-mq-guards.out Wed Aug 11 20:16:22 2010 +0800 +++ b/tests/test-mq-guards.out Thu Aug 05 12:25:53 2010 +0200 @@ -84,10 +84,16 @@ a.patch: +1 +2 -3 b.patch: +2 c.patch: unguarded +% have at least one patch applied to test coloring +applying b.patch +now at: b.patch % list patches and guards with color -a.patch: +1 +2 -3 -b.patch: +2 -c.patch: unguarded +a.patch: +1 +2 -3 +b.patch: +2 +c.patch: unguarded +% should pop b.patch +popping b.patch +patch queue now empty % list series 0 G a.patch 1 U b.patch