log: do no expect templateresources() returning a dict
authorYuya Nishihara <yuya@tcha.org>
Thu, 15 Mar 2018 20:27:38 +0900
changeset 37072 d64ae4fef471
parent 37071 d3f7930a9563
child 37073 44757e6dad93
log: do no expect templateresources() returning a dict The resources dict will be replaced with new resource mapper object, which won't implement __getitem__(key). Share the whole resources object with _graphnodeformater() to make porting easier.
mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py	Fri Mar 16 23:11:55 2018 +0900
+++ b/mercurial/logcmdutil.py	Thu Mar 15 20:27:38 2018 +0900
@@ -416,13 +416,13 @@
     def __init__(self, ui, repo, tmplspec, differ=None, diffopts=None,
                  buffered=False):
         changesetprinter.__init__(self, ui, repo, differ, diffopts, buffered)
-        tres = formatter.templateresources(ui, repo)
+        # tres is shared with _graphnodeformatter()
+        self._tresources = tres = formatter.templateresources(ui, repo)
         self.t = formatter.loadtemplater(ui, tmplspec,
                                          defaults=templatekw.keywords,
                                          resources=tres,
                                          cache=templatekw.defaulttempl)
         self._counter = itertools.count()
-        self._getcache = tres['cache']  # shared with _graphnodeformatter()
 
         self._tref = tmplspec.ref
         self._parts = {'header': '', 'footer': '',
@@ -844,10 +844,11 @@
         return templatekw.getgraphnode  # fast path for "{graphnode}"
 
     spec = templater.unquotestring(spec)
-    tres = formatter.templateresources(ui)
     if isinstance(displayer, changesettemplater):
         # reuse cache of slow templates
-        tres['cache'] = displayer._getcache
+        tres = displayer._tresources
+    else:
+        tres = formatter.templateresources(ui)
     templ = formatter.maketemplater(ui, spec, defaults=templatekw.keywords,
                                     resources=tres)
     def formatnode(repo, ctx):