changeset 38440:3813c6b7337c

templater: remove redundant member variables from templater class We no longer need them since the engine is instantiated in __init__().
author Yuya Nishihara <yuya@tcha.org>
date Thu, 21 Jun 2018 22:33:42 +0900
parents 256581484c7f
children e219e355e088
files mercurial/templater.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Jun 21 22:27:30 2018 +0900
+++ b/mercurial/templater.py	Thu Jun 21 22:33:42 2018 +0900
@@ -863,17 +863,11 @@
         self.cache may be updated later to register additional template
         fragments.
         """
-        if filters is None:
-            filters = {}
-        if defaults is None:
-            defaults = {}
-        self._filters = templatefilters.filters.copy()
-        self._filters.update(filters)
-        self.defaults = defaults
-        self._resources = resources
+        allfilters = templatefilters.filters.copy()
+        if filters:
+            allfilters.update(filters)
         self._loader = loader(cache, aliases)
-        self._proc = engine(self._loader.load, self._filters, self.defaults,
-                            self._resources)
+        self._proc = engine(self._loader.load, allfilters, defaults, resources)
         self._minchunk, self._maxchunk = minchunk, maxchunk
 
     @classmethod
@@ -894,6 +888,15 @@
     def cache(self):
         return self._loader.cache
 
+    # for highlight extension to insert one-time 'colorize' filter
+    @property
+    def _filters(self):
+        return self._proc._filters
+
+    @property
+    def defaults(self):
+        return self._proc._defaults
+
     def load(self, t):
         """Get parsed tree for the given template name. Use a local cache."""
         return self._loader.load(t)