diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -618,9 +618,14 @@ def shownamespaces(**args): repo = ctx.repo() namespaces = util.sortdict() + def makensmapfn(ns): + # 'name' for iterating over namespaces, templatename for local reference + return lambda v: {'name': v, ns.templatename: v} for k, ns in repo.names.iteritems(): - namespaces[k] = showlist('name', ns.names(repo, ctx.node()), args) + names = ns.names(repo, ctx.node()) + f = _showlist('name', names, args) + namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity) f = _showlist('namespace', list(namespaces), args) diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -4130,6 +4130,9 @@ Test namespaces dict $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}' bar foo + $ hg log -r2 -T '{namespaces.bookmarks % "{bookmark}\n"}' + bar + foo Test stringify on sub expressions