[PATCH 12 of 12] templater: add a method to list labels in a namespace

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 21 03:01:19 CDT 2014



On 08/18/2014 02:18 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1408394323 18000
> #      Mon Aug 18 15:38:43 2014 -0500
> # Node ID fe9b72aa7e160e690813cfe4242b013fb147937e
> # Parent  e1ab9da20be237323a1340efa16b58b03525596f
> templater: add a method to list labels in a namespace

I'm not sure about what this new function does. And the lack fo 
documentation does not helps.

It also lack tests (as, I just realised, this whole series)

>
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -357,10 +357,23 @@ def color(context, mapping, args):
>           raise error.ParseError(_("color expects two arguments"))
>
>       # ignore args[0] (the color string) since this is supposed to be a a no-op
>       yield _evalifliteral(args[1], context, mapping)
>
> +def labels(context, mapping, args):
> +    if len(args) != 1:
> +        # i18n: "label" is a keyword
> +        raise error.ParseError(_("labels expects one argument"))
> +
> +    ctx = mapping['ctx']
> +    repo = ctx._repo
> +    namespace = args[0][1]
> +    l = sorted(l[0] for l in repo.nodelabels(ctx.node())
> +               if l[1] == namespace)
> +
> +    return templatekw.showlist('label', l, **mapping)
> +
>   def revset(context, mapping, args):
>       """usage: revset(query[, formatargs...])
>       """
>       if not len(args) > 0:
>           # i18n: "revset" is a keyword
> @@ -517,10 +530,11 @@ funcs = {
>       "if": if_,
>       "ifcontains": ifcontains,
>       "ifeq": ifeq,
>       "join": join,
>       "label": color, # backwards compatibility before 3.1
> +    "labels": labels,
>       "pad": pad,
>       "revset": revset,
>       "rstdoc": rstdoc,
>       "shortest": shortest,
>       "startswith": startswith,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list