color: simplify & improve colorization of qseries
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Wed, 05 Aug 2009 15:00:44 +0200
changeset 9311 e37e9904bf10
parent 9310 5724cd7b3688
child 9312 c5f0825c1dbb
color: simplify & improve colorization of qseries Use 'repo.mq.series' to obtain patch names, instead of deriving them from the qseries output. This is both simpler and more robust, and fixes colorization of patches without a message with -s/--summary.
hgext/color.py
--- a/hgext/color.py	Wed Aug 05 14:44:36 2009 +0200
+++ b/hgext/color.py	Wed Aug 05 15:00:44 2009 +0200
@@ -59,6 +59,7 @@
 '''
 
 import os, sys
+import itertools
 
 from mercurial import cmdutil, commands, extensions, error
 from mercurial.i18n import _
@@ -142,14 +143,10 @@
     '''run the qseries command with colored output'''
     ui.pushbuffer()
     retval = orig(ui, repo, **opts)
-    patches = ui.popbuffer().splitlines()
-    for patch in patches:
-        patchname = patch
-        if opts['summary']:
-            patchname = patchname.split(': ', 1)[0]
-        if ui.verbose:
-            patchname = patchname.lstrip().split(' ', 2)[-1]
+    patchlines = ui.popbuffer().splitlines()
+    patchnames = repo.mq.series
 
+    for patch, patchname in itertools.izip(patchlines, patchnames):
         if opts['missing']:
             effects = _patch_effects['missing']
         # Determine if patch is applied.