Patchwork [1,of,2,stable] color: turn colorui functions into forwards when color is None

login
register
mail settings
Submitter Siddharth Agarwal
Date April 19, 2013, 11:58 p.m.
Message ID <f1a1080137afc080daae.1366415931@sid0x220>
Download mbox | patch
Permalink /patch/1461/
State Accepted
Commit b7b50a54bec9be298ac17bccda60e67b6d0d90a5
Headers show

Comments

Siddharth Agarwal - April 19, 2013, 11:58 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1366415840 25200
#      Fri Apr 19 16:57:20 2013 -0700
# Branch stable
# Node ID f1a1080137afc080daae6f0cbfa255e1409a7ebb
# Parent  9aaf1b75a303d16a096dde0bcc17a15136c364e5
color: turn colorui functions into forwards when color is None

colorui will be set to None as necessary in an upcoming patch.

Patch

diff -r 9aaf1b75a303 -r f1a1080137af hgext/color.py
--- a/hgext/color.py	Wed Apr 10 00:50:40 2013 -0700
+++ b/hgext/color.py	Fri Apr 19 16:57:20 2013 -0700
@@ -317,6 +317,9 @@  def configstyles(ui):
 
 class colorui(uimod.ui):
     def popbuffer(self, labeled=False):
+        if self._colormode is None:
+            return super(colorui, self).popbuffer(labeled)
+
         if labeled:
             return ''.join(self.label(a, label) for a, label
                            in self._buffers.pop())
@@ -324,6 +327,9 @@  class colorui(uimod.ui):
 
     _colormode = 'ansi'
     def write(self, *args, **opts):
+        if self._colormode is None:
+            return super(colorui, self).write(*args, **opts)
+
         label = opts.get('label', '')
         if self._buffers:
             self._buffers[-1].extend([(str(a), label) for a in args])
@@ -335,6 +341,9 @@  class colorui(uimod.ui):
                 *[self.label(str(a), label) for a in args], **opts)
 
     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._colormode == 'win32':
             for a in args:
@@ -344,6 +353,9 @@  class colorui(uimod.ui):
                 *[self.label(str(a), label) for a in args], **opts)
 
     def label(self, msg, label):
+        if self._colormode is None:
+            return super(colorui, self).label(msg, label)
+
         effects = []
         for l in label.split():
             s = _styles.get(l, '')