Patchwork [07,of,13,V2] color: add multiple messages input support to 'win32print'

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 24, 2017, 10:09 p.m.
Message ID <d5355608d838bda4e67f.1487974181@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18762/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 24, 2017, 10:09 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1487968447 -3600
#      Fri Feb 24 21:34:07 2017 +0100
# Node ID d5355608d838bda4e67f5855bea85a7e1b2806c0
# Parent  a13f493b42dd655ebed3d291181510e2607b9512
# EXP-Topic color
color: add multiple messages input support to 'win32print'

All other function doing writes support any number of input message. For
simplicity, we make 'win32print' able to do the same.

Patch

diff -r a13f493b42dd -r d5355608d838 hgext/color.py
--- a/hgext/color.py	Fri Feb 24 21:31:47 2017 +0100
+++ b/hgext/color.py	Fri Feb 24 21:34:07 2017 +0100
@@ -308,8 +308,7 @@  class colorui(uimod.ui):
             else:
                 self._buffers[-1].extend(args)
         elif self._colormode == 'win32':
-            for a in args:
-                color.win32print(a, super(colorui, self).write, **opts)
+            color.win32print(super(colorui, self).write, *args, **opts)
         else:
             return super(colorui, self).write(
                 *[self.label(a, label) for a in args], **opts)
@@ -322,8 +321,7 @@  class colorui(uimod.ui):
         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)
+            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)
diff -r a13f493b42dd -r d5355608d838 mercurial/color.py
--- a/mercurial/color.py	Fri Feb 24 21:31:47 2017 +0100
+++ b/mercurial/color.py	Fri Feb 24 21:34:07 2017 +0100
@@ -288,7 +288,12 @@  if pycompat.osname == 'nt':
             ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
                                 re.MULTILINE | re.DOTALL)
 
-    def win32print(text, writefunc, **opts):
+
+    def win32print(writefunc, *msgs, **opts):
+        for text in msgs:
+            _win32print(text, writefunc, **opts)
+
+    def _win32print(text, writefunc, **opts):
         label = opts.get('label', '')
         attr = origattr