mercurial/templatekw.py
changeset 44728 59ad165f6cdb
parent 44712 a825bfbf6642
child 44856 b7808443ed6a
--- 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