changeset 34716:d36a36ca7bc2

templates: introduce labelcset() function in map-cmdline.default as example
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 Oct 2017 18:24:01 +0900
parents f17a0e18c47e
children 06b52671552b
files mercurial/templates/map-cmdline.default
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templates/map-cmdline.default	Sat Oct 14 18:06:42 2017 +0900
+++ b/mercurial/templates/map-cmdline.default	Sat Oct 14 18:24:01 2017 +0900
@@ -30,19 +30,12 @@
                                                % ' {name} ({source})'}\n"))}'
 
 # General templates
-_instability_label = 'instability.{instability}'
-_troubles_labels = '{if(instabilities, "changeset.unstable {instabilities%_instability_label}")}'
-_obsolete_label = '{if(obsolete, "changeset.obsolete")}'
-_cset_labels = '{separate(" ", "log.changeset", "changeset.{phase}", "{_obsolete_label}", "{_troubles_labels}")}'
-cset = '{label("{_cset_labels}",
-               "changeset:   {rev}:{node|short}")}\n'
+cset = '{labelcset("changeset:   {rev}:{node|short}")}\n'
+fullcset = '{labelcset("changeset:   {rev}:{node}")}\n'
 
 lphase = '{label("log.phase",
                  "phase:       {phase}")}\n'
 
-fullcset = '{label("{_cset_labels}",
-                   "changeset:   {rev}:{node}")}\n'
-
 parent = '{label("log.parent changeset.{phase}",
                   "parent:      {rev}:{node|formatnode}")}\n'
 
@@ -82,3 +75,12 @@
                                        '{desc|strip}')}\n\n")}'
 
 status = '{status} {path}\n{if(copy, "  {copy}\n")}'
+
+[templatealias]
+labelcset(expr) = label(separate(" ",
+                                 "log.changeset",
+                                 "changeset.{phase}",
+                                 if(obsolete, "changeset.obsolete"),
+                                 if(instabilities, "changeset.unstable"),
+                                 instabilities % "instability.{instability}"),
+                        expr)