mercurial/formatter.py
changeset 36982 255f635c3204
parent 36921 32f9b7e3f056
child 36983 036e4483d3a1
--- a/mercurial/formatter.py	Sat Mar 17 21:46:17 2018 -0400
+++ b/mercurial/formatter.py	Sun Mar 11 21:05:29 2018 +0900
@@ -501,14 +501,23 @@
 def templateresources(ui, repo=None):
     """Create a dict of template resources designed for the default templatekw
     and function"""
-    return {
+    resmap = {
         'cache': {},  # for templatekw/funcs to store reusable data
-        'ctx': None,
         'repo': repo,
-        'revcache': None,  # per-ctx cache; set later
         'ui': ui,
     }
 
+    def getsome(context, mapping, key):
+        return resmap.get(key)
+
+    return {
+        'cache': getsome,
+        'ctx': getsome,
+        'repo': getsome,
+        'revcache': getsome,  # per-ctx cache; set later
+        'ui': getsome,
+    }
+
 def formatter(ui, out, topic, opts):
     template = opts.get("template", "")
     if template == "json":