diff 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
line wrap: on
line diff
--- a/mercurial/templatekw.py	Wed Apr 15 20:10:35 2020 +0200
+++ b/mercurial/templatekw.py	Thu Apr 16 22:30:11 2020 +0900
@@ -562,7 +562,11 @@
     """helper method to generate a template keyword for a namespace"""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    ns = repo.names[namespace]
+    ns = repo.names.get(namespace)
+    if ns is None:
+        # namespaces.addnamespace() registers new template keyword, but
+        # the registered namespace might not exist in the current repo.
+        return
     names = ns.names(repo, ctx.node())
     return compatlist(
         context, mapping, ns.templatename, names, plural=namespace