qguard: label patch names by status when listing guards
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Thu, 05 Aug 2010 12:25:53 +0200
changeset 11819 1c00577b0298
parent 11817 d12fe809e1ee
child 11820 75de514a50f3
qguard: label patch names by status when listing guards
hgext/mq.py
tests/test-mq-guards
tests/test-mq-guards.out
--- 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']:
--- 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
--- 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