templates: introduce labelcset() function in map-cmdline.default as example
authorYuya Nishihara <yuya@tcha.org>
Sat, 14 Oct 2017 18:24:01 +0900
changeset 34716 d36a36ca7bc2
parent 34715 f17a0e18c47e
child 34717 06b52671552b
templates: introduce labelcset() function in map-cmdline.default as example
mercurial/templates/map-cmdline.default
--- 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)