adding log command to color extension

Gilles Moris gilles.moris at free.fr
Sat Mar 20 07:24:23 CDT 2010


On Friday 19 March 2010 11:22:59 pm Brodie Rao wrote:
> I agree with Martin, and I think yellow'd be nice. I've done something
> similar in a patch series I'm working on for direct color/annotation
> support (as opposed to parsing/wrapping output). Highlighting each
> changeset line makes scanning a lot easier, especially when displaying
> diffs with hg log -p.

I came up wrapping changeset_printer._show instead of changeset_printer.showpatch.
However, I'd like the 'hg log -v' highlight the commit message, which is not
currently possible because there is no prefix to be parsed.
I think your direct color support will help here.
Is this the core tagged write that have been discussed at some point of time ?
When will this be ready ?
In the mean time, do you think it's worth looking that way (I also colorized
tags and branches, could be useful; tested on dark and light background):

diff -r 5afd27ae8935 hgext/color.py
--- a/hgext/color.py    Thu Feb 12 22:55:51 2009 +0100
+++ b/hgext/color.py    Sat Mar 20 13:19:30 2010 +0100
@@ -228,11 +228,11 @@
         return '\n'.join(lines)
     orig(*[_colorize(s) for s in args])

-def colorshowpatch(orig, self, node):
-    '''wrap cmdutil.changeset_printer.showpatch with colored output'''
+def colorshow(orig, self, ctx, copies, props):
+    '''wrap cmdutil.changeset_printer._show with colored output'''
     oldwrite = extensions.wrapfunction(self.ui, 'write', colorwrap)
     try:
-        orig(self, node)
+        orig(self, ctx, copies, props)
     finally:
         self.ui.write = oldwrite

@@ -280,7 +280,11 @@
                   ('+++', 'file_b'),
                   ('@', 'hunk'),
                   ('-', 'deleted'),
-                  ('+', 'inserted')]
+                  ('+', 'inserted'),
+                  ('changeset', 'change'),
+                  ('branch', 'branches'),
+                  ('tag', 'tags'),
+                  ('summary', 'message')]

 _diff_effects = {'diffline': ['bold'],
                  'extended': ['cyan', 'bold'],
@@ -290,7 +294,11 @@
                  'deleted': ['red'],
                  'inserted': ['green'],
                  'changed': ['white'],
-                 'trailingwhitespace': ['bold', 'red_background']}
+                 'trailingwhitespace': ['bold', 'red_background'],
+                 'change': ['inverse'],
+                 'branches': ['yellow'],
+                 'tags': ['cyan'],
+                 'message': ['blue', 'bold']}

 def extsetup(ui):
     '''Initialize the extension.'''
@@ -342,8 +350,8 @@
             del opts['color']
             return orig(*args, **opts)

-        oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
-                                               'showpatch', colorshowpatch)
+        oldshow = extensions.wrapfunction(cmdutil.changeset_printer,
+                                               '_show', colorshow)
         del opts['no_color']
         del opts['color']
         try:
@@ -351,7 +359,7 @@
                 return func(orig, *args, **opts)
             return orig(*args, **opts)
         finally:
-            cmdutil.changeset_printer.showpatch = oldshowpatch
+            cmdutil.changeset_printer._show = oldshow

     entry = extensions.wrapcommand(table, cmd, nocolor)
     entry[1].extend([




More information about the Mercurial-devel mailing list