Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatekw.py @ 27894:a94f7eef3199
templatekw: add {namespaces} keyword
This provides a general-purpose interface to all custom namespaces.
The {namespaces} keyword honors the definition order of namespaces as they
are kept by sortdict.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 12 Jan 2016 23:56:48 +0900 |
parents | b42b2e86ef02 |
children | ab8107c923b4 |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Jan 12 23:53:56 2016 +0900 +++ b/mercurial/templatekw.py Tue Jan 12 23:56:48 2016 +0900 @@ -421,6 +421,19 @@ names = ns.names(repo, ctx.node()) return showlist(ns.templatename, names, plural=namespace, **args) +def shownamespaces(**args): + """:namespaces: Dict of lists. Names attached to this changeset per + namespace.""" + ctx = args['ctx'] + repo = ctx.repo() + namespaces = util.sortdict((k, showlist('name', ns.names(repo, ctx.node()), + **args)) + for k, ns in repo.names.iteritems()) + f = _showlist('namespace', list(namespaces), **args) + return _hybrid(f, namespaces, + lambda k: {'namespace': k, 'names': namespaces[k]}, + lambda x: x['namespace']) + def shownode(repo, ctx, templ, **args): """:node: String. The changeset identification hash, as a 40 hexadecimal digit string. @@ -537,6 +550,7 @@ 'latesttag': showlatesttag, 'latesttagdistance': showlatesttagdistance, 'manifest': showmanifest, + 'namespaces': shownamespaces, 'node': shownode, 'p1rev': showp1rev, 'p1node': showp1node,