templater: move function table to the "context" object
authorYuya Nishihara <yuya@tcha.org>
Thu, 08 Mar 2018 22:20:36 +0900
changeset 36918 543afbdc8e59
parent 36917 f0a851542a05
child 36919 da2977e674a3
templater: move function table to the "context" object Prepares for splitting template functions from templater.py.
mercurial/templater.py
--- a/mercurial/templater.py	Sun Mar 11 16:29:54 2018 -0700
+++ b/mercurial/templater.py	Thu Mar 08 22:20:36 2018 +0900
@@ -493,8 +493,8 @@
         filt = context._filters[n]
         arg = compileexp(exp[1], context, methods)
         return (runfilter, (arg, filt))
-    if n in funcs:
-        f = funcs[n]
+    if n in context._funcs:
+        f = context._funcs[n]
         args = _buildfuncargs(exp[1], context, methods, n, f._argspec)
         return (f, args)
     raise error.ParseError(_("unknown function '%s'") % n)
@@ -595,8 +595,8 @@
 
 def buildfunc(exp, context):
     n = getsymbol(exp[1])
-    if n in funcs:
-        f = funcs[n]
+    if n in context._funcs:
+        f = context._funcs[n]
         args = _buildfuncargs(exp[2], context, exprmethods, n, f._argspec)
         return (f, args)
     if n in context._filters:
@@ -1376,6 +1376,7 @@
         if filters is None:
             filters = {}
         self._filters = filters
+        self._funcs = funcs  # make this a parameter if needed
         if defaults is None:
             defaults = {}
         if resources is None: