@@ -22,7 +22,10 @@ function (aka ANSI escape codes).
Text receives color effects depending on the labels that it has. Many
default Mercurial commands emit labelled text. You can also define
your own labels in templates using the label function, see `hg help
-templates`.
+templates`. Labels are normally invisible. In order to see these
+labels and their position in the text, use the global --color=debug
+option. A single portion of text may have more than one label. In this
+case, the multiple labels will be enclosed by brackets.
The following are the default effects for some default labels. Default
effects may be overridden from your configuration file::
@@ -179,6 +182,9 @@ def _terminfosetup(ui, mode):
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:
@@ -393,10 +399,24 @@ class colorui(uimod.ui):
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, '')
@@ -442,7 +462,7 @@ def uisetup(ui):
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)
@@ -452,9 +472,9 @@ def uisetup(ui):
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')
@@ -20,6 +20,14 @@ hg status in repo root:
\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 @@ Make sure ui.formatted=False works
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