Patchwork [1,of,5,STABLE] color: avoid win32 side effect on unrelated mapping

login
register
mail settings
Submitter Pierre-Yves David
Date May 1, 2017, 2:03 p.m.
Message ID <aac8744576ced029e5f8.1493647411@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20332/
State Accepted
Headers show

Comments

Pierre-Yves David - May 1, 2017, 2:03 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# 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.

Patch

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))