# HG changeset patch # User Sean Farley # Date 2014-12-15 03:15:37 # Node ID 40fcf6c0521781ef981f0490d71712f1ac27c135 # Parent 807ee1a02bb0ab582407f5691d5790d84dd7c056 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. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -378,6 +378,14 @@ def showtags(**args): """: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: