Patchwork [2,of,2,STABLE,v2] template-phases: do not show description or summary if empty

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date April 24, 2015, 6:57 p.m.
Message ID <ea0edbbb9c54c6bb900e.1429901862@Iris>
Download mbox | patch
Permalink /patch/8786/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - April 24, 2015, 6:57 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1429901532 14400
#      Fri Apr 24 14:52:12 2015 -0400
# Branch stable
# Node ID ea0edbbb9c54c6bb900ea0e85ae57a30e2e38fec
# Parent  c5587e1f00ff6b2294eaec42488318bd4353c43c
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.
Matt Mackall - April 24, 2015, 7:16 p.m.
On Fri, 2015-04-24 at 14:57 -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1429901532 14400
> #      Fri Apr 24 14:52:12 2015 -0400
> # Branch stable
> # Node ID ea0edbbb9c54c6bb900ea0e85ae57a30e2e38fec
> # Parent  c5587e1f00ff6b2294eaec42488318bd4353c43c
> template-phases: do not show description or summary if empty

These are queued for stable, thanks.

Patch

diff --git a/mercurial/templates/map-cmdline.phases b/mercurial/templates/map-cmdline.phases
--- a/mercurial/templates/map-cmdline.phases
+++ b/mercurial/templates/map-cmdline.phases
@@ -58,8 +58,8 @@  bookmark = '{label("log.bookmark",
 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 @@  ldate = '{label("log.date",
 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")}'
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -101,23 +101,72 @@  following below omit it properly.
   $ 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 -u0 log.out phases.out | grep -v '^---\|^+++'
+  @@ -2,0 +3 @@
+  +phase:       draft
+  @@ -6,0 +8 @@
+  +phase:       draft
+  @@ -11,0 +14 @@
+  +phase:       draft
+  @@ -17,0 +21 @@
+  +phase:       draft
+  @@ -24,0 +29 @@
+  +phase:       draft
+  @@ -31,0 +37 @@
+  +phase:       draft
+  @@ -36,0 +43 @@
+  +phase:       draft
+  @@ -41,0 +49 @@
+  +phase:       draft
+  @@ -46,0 +55 @@
+  +phase:       draft
+  @@ -51,0 +61 @@
+  +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 -u0 log.out phases.out | grep -v '^---\|^+++'
+  @@ -2,0 +3 @@
+  +phase:       draft
+  @@ -7,0 +9 @@
+  +phase:       draft
+  @@ -15,0 +18 @@
+  +phase:       draft
+  @@ -24,0 +28 @@
+  +phase:       draft
+  @@ -33,0 +38 @@
+  +phase:       draft
+  @@ -43,0 +49 @@
+  +phase:       draft
+  @@ -50,0 +57 @@
+  +phase:       draft
+  @@ -58,0 +66 @@
+  +phase:       draft
+  @@ -66,0 +75 @@
+  +phase:       draft
+  @@ -77,0 +87 @@
+  +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 +179,66 @@  Default style should also preserve color
   $ 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 -u0 log.out phases.out | grep -v '^---\|^+++'
+  @@ -2,0 +3 @@
+  +[log.phase|phase:       draft]
+  @@ -6,0 +8 @@
+  +[log.phase|phase:       draft]
+  @@ -11,0 +14 @@
+  +[log.phase|phase:       draft]
+  @@ -17,0 +21 @@
+  +[log.phase|phase:       draft]
+  @@ -24,0 +29 @@
+  +[log.phase|phase:       draft]
+  @@ -31,0 +37 @@
+  +[log.phase|phase:       draft]
+  @@ -36,0 +43 @@
+  +[log.phase|phase:       draft]
+  @@ -41,0 +49 @@
+  +[log.phase|phase:       draft]
+  @@ -46,0 +55 @@
+  +[log.phase|phase:       draft]
+  @@ -51,0 +61 @@
+  +[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 -u0 log.out phases.out | grep -v '^---\|^+++'
+  @@ -2,0 +3 @@
+  +[log.phase|phase:       draft]
+  @@ -7,0 +9 @@
+  +[log.phase|phase:       draft]
+  @@ -15,0 +18 @@
+  +[log.phase|phase:       draft]
+  @@ -24,0 +28 @@
+  +[log.phase|phase:       draft]
+  @@ -33,0 +38 @@
+  +[log.phase|phase:       draft]
+  @@ -43,0 +49 @@
+  +[log.phase|phase:       draft]
+  @@ -50,0 +57 @@
+  +[log.phase|phase:       draft]
+  @@ -58,0 +66 @@
+  +[log.phase|phase:       draft]
+  @@ -66,0 +75 @@
+  +[log.phase|phase:       draft]
+  @@ -77,0 +87 @@
+  +[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