changeset 31103:c1997c5d1ae3

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 21 Feb 2017 17:51:43 +0100
parents 96d561c90ad0
children 8346b2f09e79
files hgext/color.py mercurial/color.py
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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'