# HG changeset patch # User Kevin Bullock # Date 1254942080 18000 # Node ID 3e698434b990df03e7915c5c5ebf9925fa39d34b # Parent 3bcb28131babde24d22114d044ab220bb0d901bd color: allow multiple args to ui.write() diff -r 3bcb28131bab -r 3e698434b990 hgext/color.py --- 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'''