# HG changeset patch
# User Pierre-Yves David <pierre-yves.da...@ens-lyon.org>
# Date 1487590943 -3600
#      Mon Feb 20 12:42:23 2017 +0100
# Node ID 419d5f42cc7b764f5304b2518146824329c32f91
# Parent  620683bba165d6bbb9c6f163516102aaa264f980
# EXP-Topic color
color: move 'write-err' logic to the core ui class

This is similar to what we needed for 'write', we move the logic from the
extension to the core class. Beside the dispatch to 'win32print', we just apply
label to the argument.

diff -r 620683bba165 -r 419d5f42cc7b hgext/color.py
--- a/hgext/color.py    Fri Feb 24 19:53:41 2017 +0100
+++ b/hgext/color.py    Mon Feb 20 12:42:23 2017 +0100
@@ -297,19 +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':
-            color.win32print(super(colorui, self).write_err, *args, **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 620683bba165 -r 419d5f42cc7b mercurial/ui.py
--- a/mercurial/ui.py   Fri Feb 24 19:53:41 2017 +0100
+++ b/mercurial/ui.py   Mon Feb 20 12:42:23 2017 +0100
@@ -823,8 +823,17 @@ class ui(object):
     def write_err(self, *args, **opts):
         self._progclear()
         if self._bufferstates and self._bufferstates[-1][0]:
-            return self.write(*args, **opts)
-        self._write_err(*args, **opts)
+            self.write(*args, **opts)
+        elif self._colormode == 'win32':
+            # windows color printing is its own can of crab, defer to
+            # the color module and that is it.
+            color.win32print(self._write_err, *args, **opts)
+        else:
+            msgs = args
+            if self._colormode is not None:
+                label = opts.get('label', '')
+                msgs = [self.label(a, label) for a in args]
+            self._write_err(*msgs, **opts)
 
     def _write_err(self, *msgs, **opts):
         try:
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to