[PATCH] color: add debugcolor command (issue4094)

Olle Lundberg olle.lundberg at gmail.com
Tue Feb 11 18:07:46 CST 2014


# HG changeset patch
# User Olle Lundberg <geek at nerd.sh>
# Date 1392163251 -3600
#      Wed Feb 12 01:00:51 2014 +0100
# Node ID 7fe39106c0e1971f9e26548ebce9125d42662563
# Parent  1478a9ce679097c03234201d179e48c58d0b5c1d
color: add debugcolor command (issue4094)

This patch adds a debugcolor command that prints all
colors that the extension knows about.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -424,10 +424,20 @@
          # i18n: 'always', 'auto', and 'never' are keywords and should
          # not be translated
          _("when to colorize (boolean, always, auto, or never)"),
          _('TYPE')))
 
+def debugcolor(ui, repo, **opts):
+    global _styles
+    _styles = {}
+    for effect in _effects.keys():
+        _styles[effect] = effect
+    ui.write(('colormode: %s\n') % ui._colormode)
+    ui.write(_('available colors:\n'))
+    for label, colors in _styles.items():
+        ui.write(('%s\n') % colors, label=label)
+
 if os.name != 'nt':
     w32effects = None
 else:
     import re, ctypes
 
@@ -553,5 +563,10 @@
                 orig(m.group(2), **opts)
                 m = re.match(ansire, m.group(3))
         finally:
             # Explicitly reset original attributes
             _kernel32.SetConsoleTextAttribute(stdout, origattr)
+
+cmdtable = {
+    'debugcolor':
+        (debugcolor, [], ('hg debugcolor'))
+}


More information about the Mercurial-devel mailing list