[PATCH 11 of 12] templatekw: add a keyword to list all labels

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 21 03:00:08 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 1408394525 18000
> #      Mon Aug 18 15:42:05 2014 -0500
> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
> templatekw: add a keyword to list all labels
>
> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -374,10 +374,16 @@ def showsubrepos(**args):
>
>   def showtags(**args):
>       """:tags: List of strings. Any tags associated with the changeset."""
>       return showlist('tag', args['ctx'].tags(), **args)
>
> +def showlabels(**args):
> +    """:tags: List of strings. Any labels in the namespace `namespace`
> +    associated with the changeset."""

did you forget to update the inital :tags: ?

Also you docstring hint that this takes an argument while the 
implementation does not.


> +    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))

isn't l[0] the namespace?

> +    return showlist('label', labels, **args)
> +

You don't perform any deduplication. should we?

>   # keywords are callables like:
>   # fn(repo, ctx, templ, cache, revcache, **args)
>   # with:
>   # repo - current repository instance
>   # ctx - the changectx being displayed
> @@ -400,10 +406,11 @@ keywords = {
>       'file_copies': showfilecopies,
>       'file_copies_switch': showfilecopiesswitch,
>       'file_dels': showfiledels,
>       'file_mods': showfilemods,
>       'files': showfiles,
> +    'labels': showlabels,
>       'latesttag': showlatesttag,
>       'latesttagdistance': showlatesttagdistance,
>       'manifest': showmanifest,
>       'node': shownode,
>       'p1rev': showp1rev,
> _______________________________________________
> 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