Mercurial > hg-stable
changeset 23609:40fcf6c05217
templatekw: add helper method to generate a template keyword for a namespace
This marks our second feature of the namespace api: automatic template keyword.
This patch adds a method that takes in a namespace and uses the node-to-name
map to output the list of names.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Sun, 14 Dec 2014 19:15:37 -0800 |
parents | 807ee1a02bb0 |
children | 9266d1dd6a6e |
files | mercurial/templatekw.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatekw.py Sun Dec 14 18:54:50 2014 -0800 +++ b/mercurial/templatekw.py Sun Dec 14 19:15:37 2014 -0800 @@ -378,6 +378,14 @@ """:tags: List of strings. Any tags associated with the changeset.""" return showlist('tag', args['ctx'].tags(), **args) +def shownames(namespace, **args): + """helper method to generate a template keyword for a namespace""" + ctx = args['ctx'] + repo = ctx._repo + names = repo.names.names(repo, namespace, ctx.node()) + return showlist(repo.names.templatename(namespace), names, + plural=namespace, **args) + # keywords are callables like: # fn(repo, ctx, templ, cache, revcache, **args) # with: