Mercurial > hg
changeset 31121:8fc55bbd2235
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.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sat, 25 Feb 2017 19:43:14 +0100 |
parents | c4e8fa2b1c40 |
children | 53a60e95f154 |
files | mercurial/debugcommands.py |
diffstat | 1 files changed, 16 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- 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'))