color: handle 'ui.plain()' directly in mode setup
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 21 Feb 2017 17:51:43 +0100
changeset 31103 c1997c5d1ae3
parent 31102 96d561c90ad0
child 31104 8346b2f09e79
color: handle 'ui.plain()' directly in mode setup If 'ui.plain()' is set we should not colorize. We move that logic into the function that determine and setup the color mode. As all other code respect the resulting mode this will be equivalent.
hgext/color.py
mercurial/color.py
--- a/hgext/color.py	Tue Feb 21 17:50:04 2017 +0100
+++ b/hgext/color.py	Tue Feb 21 17:51:43 2017 +0100
@@ -189,8 +189,6 @@
 testedwith = 'ships-with-hg-core'
 
 def uisetup(ui):
-    if ui.plain():
-        return
     def colorcmd(orig, ui_, opts, cmd, cmdfunc):
         mode = color._modesetup(ui_, opts['color'])
         uimod.ui._colormode = mode
--- a/mercurial/color.py	Tue Feb 21 17:50:04 2017 +0100
+++ b/mercurial/color.py	Tue Feb 21 17:51:43 2017 +0100
@@ -162,6 +162,8 @@
         _terminfo_params.clear()
 
 def _modesetup(ui, coloropt):
+    if ui.plain():
+        return None
     if coloropt == 'debug':
         return 'debug'