Patchwork [10,of,12] template: rename label to color but leave alias for backwards compatibility

login
register
mail settings
Submitter Sean Farley
Date Aug. 18, 2014, 9:18 p.m.
Message ID <f49b99874b05d0a902f8.1408396686@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/5468/
State Changes Requested
Headers show

Comments

Sean Farley - Aug. 18, 2014, 9:18 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1402609284 25200
#      Thu Jun 12 14:41:24 2014 -0700
# Node ID f49b99874b05d0a902f8ed02201d9e57fc81c684
# Parent  186ccd3d9042c0c5ec8cb9b9b4d58a7386ea1c65
template: rename label to color but leave alias for backwards compatibility
Sean Farley - Aug. 18, 2014, 9:30 p.m.
On Mon, Aug 18, 2014 at 4:18 PM, Sean Farley
<sean.michael.farley@gmail.com> wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1402609284 25200
> #      Thu Jun 12 14:41:24 2014 -0700
> # Node ID f49b99874b05d0a902f8ed02201d9e57fc81c684
> # Parent  186ccd3d9042c0c5ec8cb9b9b4d58a7386ea1c65
> template: rename label to color but leave alias for backwards compatibility

If this is too controversial / confusing for users, then we could
instead call these 'labels':

- marks (possibly confusing with obsolete markers)

(opens up thesaurus)

- pins
- tokens
- eigenvalue?
- something else
Pierre-Yves David - Aug. 21, 2014, 7:58 a.m.
On 08/18/2014 02:30 PM, Sean Farley wrote:
> On Mon, Aug 18, 2014 at 4:18 PM, Sean Farley
> <sean.michael.farley@gmail.com> wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1402609284 25200
>> #      Thu Jun 12 14:41:24 2014 -0700
>> # Node ID f49b99874b05d0a902f8ed02201d9e57fc81c684
>> # Parent  186ccd3d9042c0c5ec8cb9b9b4d58a7386ea1c65
>> template: rename label to color but leave alias for backwards compatibility
>
> If this is too controversial / confusing for users, then we could
> instead call these 'labels':
>
> - marks (possibly confusing with obsolete markers)
>
> (opens up thesaurus)
>
> - pins
> - tokens
> - eigenvalue?
> - something else


I';m also not fan of the name. but have no clue about what to pick

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -393,14 +393,14 @@  class colorui(uimod.ui):
         if effects:
             return '\n'.join([render_effects(s, effects)
                               for s in msg.split('\n')])
         return msg
 
-def templatelabel(context, mapping, args):
+def templatecolor(context, mapping, args):
     if len(args) != 2:
-        # i18n: "label" is a keyword
-        raise error.ParseError(_("label expects two arguments"))
+        # i18n: "color" is a keyword
+        raise error.ParseError(_("color expects two arguments"))
 
     # add known effects to the mapping so symbols like 'red', 'bold',
     # etc. don't need to be quoted
     mapping.update(dict([(k, k) for k in _effects]))
 
@@ -409,16 +409,16 @@  def templatelabel(context, mapping, args
     # apparently, repo could be a string that is the favicon?
     repo = mapping.get('repo', '')
     if isinstance(repo, str):
         return thing
 
-    label = templater._evalifliteral(args[0], context, mapping)
+    color = templater._evalifliteral(args[0], context, mapping)
 
     thing = templater.stringify(thing)
-    label = templater.stringify(label)
+    color = templater.stringify(color)
 
-    return repo.ui.label(thing, label)
+    return repo.ui.label(thing, color)
 
 def uisetup(ui):
     if ui.plain():
         return
     if not isinstance(ui, colorui):
@@ -430,11 +430,13 @@  def uisetup(ui):
         if mode:
             extstyles()
             configstyles(ui_)
         return orig(ui_, opts, cmd, cmdfunc)
     extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
-    templater.funcs['label'] = templatelabel
+    templater.funcs['color'] = templatecolor
+    # backwards compatibility before 3.0
+    templater.funcs['label'] = templatecolor
 
 def extsetup(ui):
     commands.globalopts.append(
         ('', 'color', 'auto',
          # i18n: 'always', 'auto', and 'never' are keywords and should
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -349,16 +349,16 @@  def join(context, mapping, args):
             first = False
         else:
             yield joiner
         yield x
 
-def label(context, mapping, args):
+def color(context, mapping, args):
     if len(args) != 2:
-        # i18n: "label" is a keyword
-        raise error.ParseError(_("label expects two arguments"))
+        # i18n: "color" is a keyword
+        raise error.ParseError(_("color expects two arguments"))
 
-    # ignore args[0] (the label string) since this is supposed to be a a no-op
+    # ignore args[0] (the color string) since this is supposed to be a a no-op
     yield _evalifliteral(args[1], context, mapping)
 
 def revset(context, mapping, args):
     """usage: revset(query[, formatargs...])
     """
@@ -509,17 +509,18 @@  methods = {
     "func": buildfunc,
     }
 
 funcs = {
     "date": date,
+    "color": color,
     "fill": fill,
     "get": get,
     "if": if_,
     "ifcontains": ifcontains,
     "ifeq": ifeq,
     "join": join,
-    "label": label,
+    "label": color, # backwards compatibility before 3.1
     "pad": pad,
     "revset": revset,
     "rstdoc": rstdoc,
     "shortest": shortest,
     "startswith": startswith,