--- 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')
--- a/tests/test-status-color.t Sun Aug 24 17:35:36 2014 -0400
+++ b/tests/test-status-color.t Sun Aug 24 17:40:27 2014 -0400
@@ -20,6 +20,14 @@
\x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
\x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
+ $ hg status --color=debug
+ status.unknown(? )status.unknown(a/1/in_a_1)
+ status.unknown(? )status.unknown(a/in_a)
+ status.unknown(? )status.unknown(b/1/in_b_1)
+ status.unknown(? )status.unknown(b/2/in_b_2)
+ status.unknown(? )status.unknown(b/in_b)
+ status.unknown(? )status.unknown(in_root)
+
hg status . in repo root:
$ hg status --color=always .
@@ -137,6 +145,13 @@
adding deleted
adding modified
adding removed
+ $ hg log --color=debug
+ [log.changeset changeset.draft](changeset: 0:389aef86a55e)
+ log.tag(tag: tip)
+ log.user(user: test)
+ log.date(date: Thu Jan 01 00:00:00 1970 +0000)
+ log.summary(summary: initial checkin)
+
$ touch modified added unknown ignored
$ hg add added
$ hg remove removed