# HG changeset patch # User Pierre-Yves David # Date 1488048194 -3600 # Node ID 8fc55bbd2235fca1986b2fbd834c4bf8d0aa955f # Parent c4e8fa2b1c40b6c16777c7d47762f1b5a1ae751c color: cleanup 'debugcolor' logic Now that style are carried by the 'ui' object, we no longer need complicated logic to restore the original style. We just need to copy the 'ui' and work on the copied version. diff -r c4e8fa2b1c40 -r 8fc55bbd2235 mercurial/debugcommands.py --- a/mercurial/debugcommands.py Tue Feb 21 18:41:37 2017 +0100 +++ b/mercurial/debugcommands.py Sat Feb 25 19:43:14 2017 +0100 @@ -357,26 +357,22 @@ return _debugdisplaycolor(ui) def _debugdisplaycolor(ui): - oldstyle = ui._styles.copy() - try: - ui._styles.clear() - for effect in color._effects.keys(): - ui._styles[effect] = effect - if ui._terminfoparams: - for k, v in ui.configitems('color'): - if k.startswith('color.'): - ui._styles[k] = k[6:] - elif k.startswith('terminfo.'): - ui._styles[k] = k[9:] - ui.write(_('available colors:\n')) - # sort label with a '_' after the other to group '_background' entry. - items = sorted(ui._styles.items(), - key=lambda i: ('_' in i[0], i[0], i[1])) - for colorname, label in items: - ui.write(('%s\n') % colorname, label=label) - finally: - ui._styles.clear() - ui._styles.update(oldstyle) + ui = ui.copy() + ui._styles.clear() + for effect in color._effects.keys(): + ui._styles[effect] = effect + if ui._terminfoparams: + for k, v in ui.configitems('color'): + if k.startswith('color.'): + ui._styles[k] = k[6:] + elif k.startswith('terminfo.'): + ui._styles[k] = k[9:] + ui.write(_('available colors:\n')) + # sort label with a '_' after the other to group '_background' entry. + items = sorted(ui._styles.items(), + key=lambda i: ('_' in i[0], i[0], i[1])) + for colorname, label in items: + ui.write(('%s\n') % colorname, label=label) def _debugdisplaystyle(ui): ui.write(_('available style:\n'))