From patchwork Mon May 1 14:03:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,5,STABLE] color: avoid win32 side effect on unrelated mapping From: Pierre-Yves David X-Patchwork-Id: 20332 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Mon, 01 May 2017 16:03:31 +0200 # HG changeset patch # User Pierre-Yves David # Date 1487714323 -3600 # Tue Feb 21 22:58:43 2017 +0100 # Node ID aac8744576ced029e5f858dbdd02819f9f942732 # Parent 8fc55bbd2235fca1986b2fbd834c4bf8d0aa955f # EXP-Topic color # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r aac8744576ce color: avoid win32 side effect on unrelated mapping The '_effect' and the 'w32effects' mapping seems unrelated. Yet in 'win32' mode, they were mixed to make sure some other code were using the 'win32effects' value through the '_effect' mapping. Instead, we simply dispatch to the right mapping according to the color mode. diff --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -237,7 +237,6 @@ def _modesetup(ui): if not w32effects: modewarn() return None - _effects.update(w32effects) elif realmode == 'ansi': ui._terminfoparams.clear() elif realmode == 'terminfo': @@ -272,7 +271,10 @@ def configstyles(ui): def valideffect(ui, effect): 'Determine if the effect is valid or not.' - return ((not ui._terminfoparams and effect in _effects) + knowneffect = _effects + if ui._colormode == 'win32': + knowneffect = w32effects + return ((not ui._terminfoparams and effect in knowneffect) or (effect in ui._terminfoparams or effect[:-11] in ui._terminfoparams))