qseries: make use of output labeling
authorBrodie Rao <brodie@bitheap.org>
Fri, 02 Apr 2010 15:22:14 -0500
changeset 10824 18def0d5692d
parent 10823 581d5e3095ef
child 10825 781689b9b6bb
qseries: make use of output labeling
hgext/mq.py
--- a/hgext/mq.py	Fri Apr 02 15:22:11 2010 -0500
+++ b/hgext/mq.py	Fri Apr 02 15:22:14 2010 -0500
@@ -1416,7 +1416,7 @@
 
     def qseries(self, repo, missing=None, start=0, length=None, status=None,
                 summary=False):
-        def displayname(pfx, patchname):
+        def displayname(pfx, patchname, state):
             if summary:
                 ph = patchheader(self.join(patchname), self.plainmode)
                 msg = ph.message and ph.message[0] or ''
@@ -1429,7 +1429,7 @@
                 msg = "%s%s: %s" % (pfx, patchname, msg)
             else:
                 msg = pfx + patchname
-            self.ui.write(msg + '\n')
+            self.ui.write(msg + '\n', label='qseries.' + state)
 
         applied = set([p.name for p in self.applied])
         if length is None:
@@ -1440,17 +1440,17 @@
             for i in xrange(start, start + length):
                 patch = self.series[i]
                 if patch in applied:
-                    stat = 'A'
+                    char, state = 'A', 'applied'
                 elif self.pushable(i)[0]:
-                    stat = 'U'
+                    char, state = 'U', 'unapplied'
                 else:
-                    stat = 'G'
+                    char, state = 'G', 'guarded'
                 pfx = ''
                 if self.ui.verbose:
-                    pfx = '%*d %s ' % (idxwidth, i, stat)
-                elif status and status != stat:
+                    pfx = '%*d %s ' % (idxwidth, i, char)
+                elif status and status != char:
                     continue
-                displayname(pfx, patch)
+                displayname(pfx, patch, state)
         else:
             msng_list = []
             for root, dirs, files in os.walk(self.path):
@@ -1464,7 +1464,7 @@
                         msng_list.append(fl)
             for x in sorted(msng_list):
                 pfx = self.ui.verbose and ('D ') or ''
-                displayname(pfx, x)
+                displayname(pfx, x, 'missing')
 
     def issaveline(self, l):
         if l.name == '.hg.patches.save.line':