templater: remove redundant member variables from templater class
authorYuya Nishihara <yuya@tcha.org>
Thu, 21 Jun 2018 22:33:42 +0900
changeset 38445 3813c6b7337c
parent 38444 256581484c7f
child 38446 e219e355e088
templater: remove redundant member variables from templater class We no longer need them since the engine is instantiated in __init__().
mercurial/templater.py
--- 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)