[PATCH 1 of 1] keyword: colorize hg kwfiles mimicking hg status

Christian Ebert blacktrash at gmx.net
Sat May 8 03:17:06 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1273306556 -7200
# Node ID 9d631c41d42baf41049acf1f8e9bd0d72520938f
# Parent  0bedcbcb3ae2caca7f8894c6b53c901475aad6a1
keyword: colorize hg kwfiles mimicking hg status

The label names are taken from hg status. However, in the cases of
status.removed and status.clean they are disassociated from their
verbal meaning in hg status in favour of of a similarity in
drawing attention/alarm:

keyword expansion candidate                 status.removed
keyword expansion candidate (not tracked)   status.unknown
ignored                                     status.ignored
ignored (not tracked)                       status.clean

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -389,10 +389,13 @@
     if opts.get('all') or opts.get('ignore'):
         showfiles += ([f for f in files if f not in kwfiles],
                       [f for f in unknown if f not in kwunknown])
-    for char, filenames in zip('KkIi', showfiles):
+    # label names from hg status with adapted semantics
+    kwlabels = 'removed unknown ignored clean'.split()
+    kwstates = zip(kwlabels, 'KkIi', showfiles)
+    for kwstate, char, filenames in kwstates:
         fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
         for f in filenames:
-            ui.write(fmt % repo.pathto(f, cwd))
+            ui.write(fmt % repo.pathto(f, cwd), label='status.' + kwstate)
 
 def shrink(ui, repo, *pats, **opts):
     '''revert expanded keywords in the working directory


More information about the Mercurial-devel mailing list