changeset 30655:27e48410380d

color: drop use of the 'global' keyword for '_style' Using 'global' is usually a bad sign. Here it is used so that one can empty the content of a dict at the global scope. We '_style.clear()' and drop the global.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 18 Nov 2016 18:29:19 +0100
parents ae37e395a110
children 1ec42bdd7874
files hgext/color.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Fri Nov 18 18:27:13 2016 +0100
+++ b/hgext/color.py	Fri Nov 18 18:29:19 2016 +0100
@@ -546,10 +546,9 @@
         return _debugdisplaycolor(ui)
 
 def _debugdisplaycolor(ui):
-    global _styles
-    oldstyle = _styles
+    oldstyle = _styles.copy()
     try:
-        _styles = {}
+        _styles.clear()
         for effect in _effects.keys():
             _styles[effect] = effect
         if _terminfo_params:
@@ -565,7 +564,8 @@
         for colorname, label in items:
             ui.write(('%s\n') % colorname, label=label)
     finally:
-        _styles = oldstyle
+        _styles.clear()
+        _styles.update(oldstyle)
 
 def _debugdisplaystyle(ui):
     ui.write(_('available style:\n'))