[PATCH 5 of 6] color: move 'write-err' logic to the core ui class
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Feb 22 11:54:36 EST 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1487590943 -3600
# Mon Feb 20 12:42:23 2017 +0100
# Node ID 707f0b5ada6d7237306d87a34ab5569b3e7c8844
# Parent 0f2be97ca31046bbf9c9f37fcdacf7b406e94054
# EXP-Topic color
color: move 'write-err' logic to the core ui class
Same as the previous commit, but for the error output.
diff -r 0f2be97ca310 -r 707f0b5ada6d hgext/color.py
--- a/hgext/color.py Mon Feb 20 12:31:39 2017 +0100
+++ b/hgext/color.py Mon Feb 20 12:42:23 2017 +0100
@@ -297,20 +297,7 @@ def _modesetup(ui, coloropt):
return None
class colorui(uimod.ui):
-
- def write_err(self, *args, **opts):
- if self._colormode is None:
- return super(colorui, self).write_err(*args, **opts)
-
- label = opts.get('label', '')
- if self._bufferstates and self._bufferstates[-1][0]:
- return self.write(*args, **opts)
- if self._colormode == 'win32':
- for a in args:
- color.win32print(a, super(colorui, self).write_err, **opts)
- else:
- return super(colorui, self).write_err(
- *[self.label(a, label) for a in args], **opts)
+ pass
def uisetup(ui):
if ui.plain():
diff -r 0f2be97ca310 -r 707f0b5ada6d mercurial/ui.py
--- a/mercurial/ui.py Mon Feb 20 12:31:39 2017 +0100
+++ b/mercurial/ui.py Mon Feb 20 12:42:23 2017 +0100
@@ -826,8 +826,18 @@ class ui(object):
with self.timeblockedsection('stdio'):
if not getattr(self.fout, 'closed', False):
self.fout.flush()
- for a in args:
- self.ferr.write(a)
+ if self._colormode == 'win32':
+ # windows color printing is its own can of crab, defer to
+ # the color module and that is it.
+ for a in args:
+ color.win32print(a, self.ferr.write, **opts)
+ else:
+ msgs = args
+ if self._colormode is not None:
+ label = opts.get('label', '')
+ msgs = [self.label(a, label) for a in args]
+ for a in msgs:
+ self.ferr.write(a)
# stderr may be buffered under win32 when redirected to files,
# including stdout.
if not getattr(self.ferr, 'closed', False):
More information about the Mercurial-devel
mailing list