template-phases: do not show description or summary if empty
This is a copy of
c1cb6523e968, but applied to the phases template,
which is itself almost a copy of the default template.
Perhaps we should rewrite these templates to use the %include syntax
afforded by config files. This change seems a bit too big for stable,
though.
--- a/mercurial/templates/map-cmdline.phases Fri Apr 24 14:17:14 2015 -0400
+++ b/mercurial/templates/map-cmdline.phases Fri Apr 24 14:52:12 2015 -0400
@@ -58,8 +58,8 @@
user = '{label("log.user",
"user: {author}")}\n'
-summary = '{label("log.summary",
- "summary: {desc|firstline}")}\n'
+summary = '{if(desc|strip, "{label('log.summary',
+ 'summary: {desc|firstline}')}\n")}'
ldate = '{label("log.date",
"date: {date|date}")}\n'
@@ -67,7 +67,7 @@
extra = '{label("ui.debug log.extra",
"extra: {key}={value|stringescape}")}\n'
-description = '{label("ui.note log.description",
- "description:")}
- {label("ui.note log.description",
- "{desc|strip}")}\n\n'
+description = '{if(desc|strip, "{label('ui.note log.description',
+ 'description:')}
+ {label('ui.note log.description',
+ '{desc|strip}')}\n\n")}'
--- a/tests/test-command-template.t Fri Apr 24 14:17:14 2015 -0400
+++ b/tests/test-command-template.t Fri Apr 24 14:52:12 2015 -0400
@@ -101,23 +101,52 @@
$ hg add c
$ hg commit -qm ' '
-Default style is like normal output.
+Default style is like normal output. Phases style should be the same
+as default style, except for extra phase lines.
$ hg log > log.out
$ hg log --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg log -T phases > phases.out
+ $ diff -u log.out phases.out | grep "phase:"
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
$ hg log -v > log.out
$ hg log -v --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg log -v -T phases > phases.out
+ $ diff -u log.out phases.out | grep phase:
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
+ +phase: draft
$ hg log -q > log.out
$ hg log -q --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg log -q -T phases > phases.out
+ $ cmp log.out phases.out || diff -u log.out phases.out
$ hg log --debug > log.out
$ hg log --debug --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg log --debug -T phases > phases.out
+ $ cmp log.out phases.out || diff -u log.out phases.out
Default style should also preserve color information (issue2866):
@@ -130,15 +159,46 @@
$ hg --color=debug log > log.out
$ hg --color=debug log --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg --color=debug log -T phases > phases.out
+ $ diff -u log.out phases.out | grep phase:
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+
$ hg --color=debug -v log > log.out
$ hg --color=debug -v log --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg --color=debug -v log -T phases > phases.out
+ $ diff -u log.out phases.out | grep phase:
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+ +[log.phase|phase: draft]
+
$ hg --color=debug -q log > log.out
$ hg --color=debug -q log --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg --color=debug -q log -T phases > phases.out
+ $ cmp log.out phases.out || diff -u log.out phases.out
+
$ hg --color=debug --debug log > log.out
$ hg --color=debug --debug log --style default > style.out
$ cmp log.out style.out || diff -u log.out style.out
+ $ hg --color=debug --debug log -T phases > phases.out
+ $ cmp log.out phases.out || diff -u log.out phases.out
$ mv $HGRCPATH-bak $HGRCPATH