# HG changeset patch # User Pierre-Yves David # Date 1479490159 -3600 # Node ID 27e48410380d020bb3b0eaf74554a0d2559eba62 # Parent ae37e395a110fed2f1f30a794953ce400e5b29cc 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. diff -r ae37e395a110 -r 27e48410380d hgext/color.py --- 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'))