[PATCH 1 of 2] keyword: colorize hg kwfiles output

Christian Ebert blacktrash at gmx.net
Sat Dec 4 08:14:18 CST 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1291468932 -3600
# Node ID 69405131c9684c56b6c6f3397fd000deb5877266
# Parent  6b8d2ee24ce2fb5d88dc201aa792ad878d06b92a
keyword: colorize hg kwfiles output

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -101,6 +101,13 @@
 # names of extensions using dorecord
 recordextensions = 'record'
 
+colortable = {
+    'kwfiles.enabled': 'green bold',
+    'kwfiles.enabledunknown': 'green',
+    'kwfiles.ignored': 'bold',
+    'kwfiles.ignoredunknown': 'none'
+}
+
 # date like in cvs' $Date
 utcdate = lambda x: util.datestr((x[0], 0), '%Y/%m/%d %H:%M:%S')
 # date like in svn's $Date
@@ -111,7 +118,6 @@
 # make keyword tools accessible
 kwtools = {'templater': None, 'hgcmd': ''}
 
-
 def _defaultkwmaps(ui):
     '''Returns default keywordmaps according to keywordset configuration.'''
     templates = {
@@ -447,10 +453,12 @@
     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):
+    kwlabels = 'enabled enabledunknown ignored ignoredunknown'.split()
+    kwstates = zip('KkIi', showfiles, kwlabels)
+    for char, filenames, kwstate 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='kwfiles.' + kwstate)
 
 def shrink(ui, repo, *pats, **opts):
     '''revert expanded keywords in the working directory


More information about the Mercurial-devel mailing list