[PATCH] color: simplify & improve colorisation of qseries

Dan Villiom Podlaski Christiansen danchr at gmail.com
Wed Jul 29 13:22:46 CDT 2009


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1248732360 -7200
# Node ID c6c3ce9186ce5ead1f2e6a015516a421b834f51d
# Parent  67a66166e4ae2ac48ec13fa777025951dcf31876
color: simplify & improve colorisation 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 colorisation of patches without a message with -s/--summary.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -59,6 +59,7 @@ Default effects may be overridden from t
 '''
 
 import os, sys
+import itertools
 
 from mercurial import cmdutil, commands, extensions, error
 from mercurial.i18n import _
@@ -142,14 +143,10 @@ def colorqseries(orig, ui, repo, *dummy,
     '''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.


More information about the Mercurial-devel mailing list