hgext/color.py
changeset 9551 3e698434b990
parent 9550 3bcb28131bab
child 9641 9b99f158348a
--- a/hgext/color.py	Thu Oct 08 09:27:22 2009 +0800
+++ b/hgext/color.py	Wed Oct 07 14:01:20 2009 -0500
@@ -162,22 +162,24 @@
 _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
                     'missing': ['red', 'bold'],
                     'unapplied': ['black', 'bold'], }
-def colorwrap(orig, s):
+def colorwrap(orig, *args):
     '''wrap ui.write for colored diff output'''
-    lines = s.split('\n')
-    for i, line in enumerate(lines):
-        stripline = line
-        if line and line[0] in '+-':
-            # highlight trailing whitespace, but only in changed lines
-            stripline = line.rstrip()
-        for prefix, style in _diff_prefixes:
-            if stripline.startswith(prefix):
-                lines[i] = render_effects(stripline, _diff_effects[style])
-                break
-        if line != stripline:
-            lines[i] += render_effects(
-                line[len(stripline):], _diff_effects['trailingwhitespace'])
-    orig('\n'.join(lines))
+    def _colorize(s):
+        lines = s.split('\n')
+        for i, line in enumerate(lines):
+            stripline = line
+            if line and line[0] in '+-':
+                # highlight trailing whitespace, but only in changed lines
+                stripline = line.rstrip()
+            for prefix, style in _diff_prefixes:
+                if stripline.startswith(prefix):
+                    lines[i] = render_effects(stripline, _diff_effects[style])
+                    break
+            if line != stripline:
+                lines[i] += render_effects(
+                    line[len(stripline):], _diff_effects['trailingwhitespace'])
+        return '\n'.join(lines)
+    orig(*[_colorize(s) for s in args])
 
 def colorshowpatch(orig, self, node):
     '''wrap cmdutil.changeset_printer.showpatch with colored output'''