# HG changeset patch # User Pierre-Yves David # Date 2017-02-21 16:51:43 # Node ID c1997c5d1ae36167fc4372219d96137a82cb4097 # Parent 96d561c90ad0a0841e549af7e35aa1f5b80ab1e2 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. diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -189,8 +189,6 @@ command = cmdutil.command(cmdtable) 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 diff --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -162,6 +162,8 @@ def _terminfosetup(ui, mode): _terminfo_params.clear() def _modesetup(ui, coloropt): + if ui.plain(): + return None if coloropt == 'debug': return 'debug'