[PATCH] qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen
danchr at gmail.com
Thu Aug 5 12:43:05 UTC 2010
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1281003953 -7200
# Node ID e58d1dabd1e30c50dbf9a14c506ea9ba54e62761
# Parent 546b0803cea1ce5dcfe2c1445746b5cd7fd19c02
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
@@ -2171,7 +2171,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')
@@ -2183,6 +2191,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: [0;33m+1[0m [0;33m+2[0m [0;31m-3[0m
-b.patch: [0;33m+2[0m
-c.patch: [0;32munguarded[0m
+[0;30;1ma.patch[0m: [0;33m+1[0m [0;33m+2[0m [0;31m-3[0m
+[0;34;1;4mb.patch[0m: [0;33m+2[0m
+[0;30;1mc.patch[0m: [0;32munguarded[0m
+% should pop b.patch
+popping b.patch
+patch queue now empty
% list series
0 G a.patch
1 U b.patch
More information about the Mercurial-devel
mailing list