[PATCH 7 of 7] color: have the 'ui' object carry the '_colormode' directly

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Feb 25 08:11:39 EST 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1487697727 -3600
#      Tue Feb 21 18:22:07 2017 +0100
# Node ID 919a50ca258e679eef69c56f5d606a287b9e33ee
# Parent  0deb181adc74dea75b109ebdf38fb73f5f20c724
# EXP-Topic color
color: have the 'ui' object carry the '_colormode' directly

Before this changeset, the value was carried by the class to work around
limitation of the extensions initialisation. Now that the initialisation is
cleanly handled in 'dispatch', we can drop this work around.

diff -r 0deb181adc74 -r 919a50ca258e mercurial/color.py
--- a/mercurial/color.py	Tue Feb 21 18:20:12 2017 +0100
+++ b/mercurial/color.py	Tue Feb 21 18:22:07 2017 +0100
@@ -168,7 +168,7 @@ def setup(ui, coloropts):
     argument. That function both set the colormode for the ui object and read
     the configuration looking for custom colors and effect definitions."""
     mode = _modesetup(ui, coloropts)
-    ui.__class__._colormode = mode
+    ui._colormode = mode
     if mode and mode != 'debug':
         configstyles(ui)
 
diff -r 0deb181adc74 -r 919a50ca258e mercurial/ui.py
--- a/mercurial/ui.py	Tue Feb 21 18:20:12 2017 +0100
+++ b/mercurial/ui.py	Tue Feb 21 18:22:07 2017 +0100
@@ -128,8 +128,6 @@ def _catchterm(*args):
     raise error.SignalInterrupt
 
 class ui(object):
-    # color mode: see mercurial/color.py for possible value
-    _colormode = None
     def __init__(self, src=None):
         """Create a fresh new ui object if no src given
 
@@ -157,6 +155,8 @@ class ui(object):
         self.insecureconnections = False
         # Blocked time
         self.logblockedtimes = False
+        # color mode: see mercurial/color.py for possible value
+        self._colormode = None
 
         if src:
             self.fout = src.fout
@@ -173,6 +173,8 @@ class ui(object):
             self.environ = src.environ
             self.callhooks = src.callhooks
             self.insecureconnections = src.insecureconnections
+            self._colormode = src._colormode
+
             self.fixconfig()
 
             self.httppasswordmgrdb = src.httppasswordmgrdb


More information about the Mercurial-devel mailing list