Mercurial > hg
comparison mercurial/templatekw.py @ 44728:59ad165f6cdb
templatekw: fix shownames() to check if namespace exists in repo (issue6301)
Namespace registration is dynamic, but the corresponding template keyword
is registered statically.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 16 Apr 2020 22:30:11 +0900 |
parents | a825bfbf6642 |
children | b7808443ed6a |
comparison
equal
deleted
inserted
replaced
44727:694d40416d62 | 44728:59ad165f6cdb |
---|---|
560 | 560 |
561 def shownames(context, mapping, namespace): | 561 def shownames(context, mapping, namespace): |
562 """helper method to generate a template keyword for a namespace""" | 562 """helper method to generate a template keyword for a namespace""" |
563 repo = context.resource(mapping, b'repo') | 563 repo = context.resource(mapping, b'repo') |
564 ctx = context.resource(mapping, b'ctx') | 564 ctx = context.resource(mapping, b'ctx') |
565 ns = repo.names[namespace] | 565 ns = repo.names.get(namespace) |
566 if ns is None: | |
567 # namespaces.addnamespace() registers new template keyword, but | |
568 # the registered namespace might not exist in the current repo. | |
569 return | |
566 names = ns.names(repo, ctx.node()) | 570 names = ns.names(repo, ctx.node()) |
567 return compatlist( | 571 return compatlist( |
568 context, mapping, ns.templatename, names, plural=namespace | 572 context, mapping, ns.templatename, names, plural=namespace |
569 ) | 573 ) |
570 | 574 |