[PATCH] color: add effect to the template symbol table
Durham Goode
durham at fb.com
Mon Apr 14 20:05:40 CDT 2014
On 4/14/14, 4:25 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1397517686 18000
> # Mon Apr 14 18:21:26 2014 -0500
> # Node ID eeba1982fac05351bbfc729ec3314eaa195eb59d
> # Parent 76f68595ff8e5616a79dd79e962a97cc9ba58713
> color: add effect to the template symbol table
>
> Previously, words like 'red' had to be protected by quotes before passing to
> the label template function. Now, we add color effects to the symbol table so
> that commands like,
>
> $ hg log -r . -T "{label(red, node|short)}\n"
>
> can work without the need for quoting.
>
> diff --git a/hgext/color.py b/hgext/color.py
> --- a/hgext/color.py
> +++ b/hgext/color.py
> @@ -393,10 +393,14 @@ class colorui(uimod.ui):
> def templatelabel(context, mapping, args):
> if len(args) != 2:
> # i18n: "label" is a keyword
> raise error.ParseError(_("label 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]))
> +
> thing = templater._evalifliteral(args[1], context, mapping)
>
> # apparently, repo could be a string that is the favicon?
> repo = mapping.get('repo', '')
> if isinstance(repo, str):
>
Sweet! Queued for default.
More information about the Mercurial-devel
mailing list