# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 2010-08-05 10:25:53 # Node ID 1c00577b029839e22116e6bd5304958e96aef29a # Parent d12fe809e1ee4b341f8f2927db416c3f0142cf22 qguard: label patch names by status when listing guards diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -2172,7 +2172,15 @@ def guard(ui, repo, *args, **opts): ''' 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 @@ def guard(ui, repo, *args, **opts): 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 --git a/tests/test-mq-guards b/tests/test-mq-guards --- a/tests/test-mq-guards +++ b/tests/test-mq-guards @@ -97,11 +97,16 @@ hg qpop -a 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 --git a/tests/test-mq-guards.out b/tests/test-mq-guards.out --- a/tests/test-mq-guards.out +++ b/tests/test-mq-guards.out @@ -84,10 +84,16 @@ number of unguarded, unapplied patches h 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