# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1412380077 14400 # Node ID 7ebf91426f6aa95bef38adf533358e8a1104822c # Parent 05b3238ba90139f5f7d2fa6687fbfcc696628ace 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. diff -r 05b3238ba901 -r 7ebf91426f6a hgext/color.py --- a/hgext/color.py Sat Oct 04 17:22:22 2014 +0900 +++ b/hgext/color.py Fri Oct 03 19:47:57 2014 -0400 @@ -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) diff -r 05b3238ba901 -r 7ebf91426f6a tests/test-status-color.t --- a/tests/test-status-color.t Sat Oct 04 17:22:22 2014 +0900 +++ b/tests/test-status-color.t Fri Oct 03 19:47:57 2014 -0400 @@ -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