Patchwork [5,of,6] templates: introduce labelcset() function in map-cmdline.default as example

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 14, 2017, 10:41 a.m.
Message ID <1fa8afb93739b8233c67.1507977674@mimosa>
Download mbox | patch
Permalink /patch/24891/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 14, 2017, 10:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1507973041 -32400
#      Sat Oct 14 18:24:01 2017 +0900
# Node ID 1fa8afb93739b8233c6744c2b59fec6e9dee073a
# Parent  48c3ed364bcac4e271d21cc1cde1c73704641b0c
templates: introduce labelcset() function in map-cmdline.default as example
Denis Laxalde - Oct. 14, 2017, 11:57 a.m.
Yuya Nishihara a écrit :
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1507973041 -32400
> #      Sat Oct 14 18:24:01 2017 +0900
> # Node ID 1fa8afb93739b8233c6744c2b59fec6e9dee073a
> # Parent  48c3ed364bcac4e271d21cc1cde1c73704641b0c
> templates: introduce labelcset() function in map-cmdline.default as example

Really nice!

I think it would be useful in map-cmdline.show to display obsolescence
information (with colors) that is currently missing.

(The series looks good to me.)

> diff --git a/mercurial/templates/map-cmdline.default b/mercurial/templates/map-cmdline.default
> --- a/mercurial/templates/map-cmdline.default
> +++ b/mercurial/templates/map-cmdline.default
> @@ -30,19 +30,12 @@ lfile_copies_switch = '{if(file_copies_s
>                                                  % ' {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 @@ description = '{if(desc|strip, "{label('
>                                          '{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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/templates/map-cmdline.default b/mercurial/templates/map-cmdline.default
--- a/mercurial/templates/map-cmdline.default
+++ b/mercurial/templates/map-cmdline.default
@@ -30,19 +30,12 @@  lfile_copies_switch = '{if(file_copies_s
                                                % ' {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 @@  description = '{if(desc|strip, "{label('
                                        '{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)