mercurial/debugcommands.py
changeset 31121 8fc55bbd2235
parent 31120 c4e8fa2b1c40
child 31216 21fa3d3688f3
equal deleted inserted replaced
31120:c4e8fa2b1c40 31121:8fc55bbd2235
   355         return _debugdisplaystyle(ui)
   355         return _debugdisplaystyle(ui)
   356     else:
   356     else:
   357         return _debugdisplaycolor(ui)
   357         return _debugdisplaycolor(ui)
   358 
   358 
   359 def _debugdisplaycolor(ui):
   359 def _debugdisplaycolor(ui):
   360     oldstyle = ui._styles.copy()
   360     ui = ui.copy()
   361     try:
   361     ui._styles.clear()
   362         ui._styles.clear()
   362     for effect in color._effects.keys():
   363         for effect in color._effects.keys():
   363         ui._styles[effect] = effect
   364             ui._styles[effect] = effect
   364     if ui._terminfoparams:
   365         if ui._terminfoparams:
   365         for k, v in ui.configitems('color'):
   366             for k, v in ui.configitems('color'):
   366             if k.startswith('color.'):
   367                 if k.startswith('color.'):
   367                 ui._styles[k] = k[6:]
   368                     ui._styles[k] = k[6:]
   368             elif k.startswith('terminfo.'):
   369                 elif k.startswith('terminfo.'):
   369                 ui._styles[k] = k[9:]
   370                     ui._styles[k] = k[9:]
   370     ui.write(_('available colors:\n'))
   371         ui.write(_('available colors:\n'))
   371     # sort label with a '_' after the other to group '_background' entry.
   372         # sort label with a '_' after the other to group '_background' entry.
   372     items = sorted(ui._styles.items(),
   373         items = sorted(ui._styles.items(),
   373                    key=lambda i: ('_' in i[0], i[0], i[1]))
   374                        key=lambda i: ('_' in i[0], i[0], i[1]))
   374     for colorname, label in items:
   375         for colorname, label in items:
   375         ui.write(('%s\n') % colorname, label=label)
   376             ui.write(('%s\n') % colorname, label=label)
       
   377     finally:
       
   378         ui._styles.clear()
       
   379         ui._styles.update(oldstyle)
       
   380 
   376 
   381 def _debugdisplaystyle(ui):
   377 def _debugdisplaystyle(ui):
   382     ui.write(_('available style:\n'))
   378     ui.write(_('available style:\n'))
   383     width = max(len(s) for s in ui._styles)
   379     width = max(len(s) for s in ui._styles)
   384     for label, effects in sorted(ui._styles.items()):
   380     for label, effects in sorted(ui._styles.items()):