--- a/hgext/color.py Sun Aug 24 17:35:36 2014 -0400
+++ b/hgext/color.py Sun Aug 24 17:40:27 2014 -0400
@@ -27,6 +27,13 @@
effects. This includes the special "none" effect, which nullifies
other effects.
+Labels are normally invisible. In order to see these labels and their
+position in the text, use the global --color=debug option. In case of
+multiple labels for the same text, the labels will be enclosed by
+square brackets, e.g.
+
+ [log.changeset changeset.secret](changeset: 22611:6f0a53c8f587)
+
The following are the default effects for some default labels. Default
effects may be overridden from your configuration file::
@@ -177,6 +184,9 @@
def _modesetup(ui, coloropt):
global _terminfo_params
+ if coloropt == 'debug':
+ return 'debug'
+
auto = (coloropt == 'auto')
always = not auto and util.parsebool(coloropt)
if not always and not auto:
@@ -387,10 +397,24 @@
return super(colorui, self).write_err(
*[self.label(str(a), label) for a in args], **opts)
+ def showlabel(self, msg, label):
+ if ' ' in label:
+ label = '[' + label + ']'
+ if label:
+ if msg and msg[-1] == '\n':
+ return "%s(%s)\n" % (label, msg[:-1])
+ else:
+ return "%s(%s)" % (label, msg)
+ else:
+ return msg
+
def label(self, msg, label):
if self._colormode is None:
return super(colorui, self).label(msg, label)
+ if self._colormode == 'debug':
+ return self.showlabel(msg, label)
+
effects = []
for l in label.split():
s = _styles.get(l, '')
@@ -436,7 +460,7 @@
def colorcmd(orig, ui_, opts, cmd, cmdfunc):
mode = _modesetup(ui_, opts['color'])
colorui._colormode = mode
- if mode:
+ if mode and mode != 'debug':
extstyles()
configstyles(ui_)
return orig(ui_, opts, cmd, cmdfunc)
@@ -446,9 +470,9 @@
def extsetup(ui):
commands.globalopts.append(
('', 'color', 'auto',
- # i18n: 'always', 'auto', and 'never' are keywords and should
- # not be translated
- _("when to colorize (boolean, always, auto, or never)"),
+ # i18n: 'always', 'auto', 'never', and 'debug' are keywords
+ # and should not be translated
+ _("when to colorize (boolean, always, auto, never, or debug)"),
_('TYPE')))
@command('debugcolor', [], 'hg debugcolor')