Skip to content
Snippets Groups Projects
Commit 7ebf91426f6a authored by Jordi Gutiérrez Hermoso's avatar Jordi Gutiérrez Hermoso
Browse files

color: omit debug label output on empty strings

This is most noticeable when using custom templates. Before this
patch, a template like {label("foo.bar", baz)} would emit

   [foo.bar|]

whenever baz was empty. This cset simply omits all output when baz is
empty.
parent 05b3238ba901
No related branches found
No related tags found
No related merge requests found
......@@ -407,8 +407,8 @@
*[self.label(str(a), label) for a in args], **opts)
def showlabel(self, msg, label):
if label:
if msg and msg[-1] == '\n':
if label and msg:
if msg[-1] == '\n':
return "[%s|%s]\n" % (label, msg[:-1])
else:
return "[%s|%s]" % (label, msg)
......
......@@ -152,6 +152,11 @@
[log.date|date: Thu Jan 01 00:00:00 1970 +0000]
[log.summary|summary: initial checkin]
Labels on empty strings should not be displayed, labels on custom
templates should be.
$ hg log --color=debug -T '{label("my.label",author)}\n{label("skipped.label","")}'
[my.label|test]
$ touch modified added unknown ignored
$ hg add added
$ hg remove removed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment