templater: pass context to itermaps() for future extension
authorYuya Nishihara <yuya@tcha.org>
Sun, 18 Mar 2018 23:24:50 +0900
changeset 37324 c2f74b8f6b7f
parent 37323 8c31b434697f
child 37325 41a5d815d2c1
templater: pass context to itermaps() for future extension Unlike show() and tovalue(), a base mapping isn't passed to itermaps() since it is the function to generate a partial mapping.
mercurial/templateutil.py
--- a/mercurial/templateutil.py	Sat Mar 17 21:21:50 2018 +0900
+++ b/mercurial/templateutil.py	Sun Mar 18 23:24:50 2018 +0900
@@ -38,7 +38,7 @@
     __metaclass__ = abc.ABCMeta
 
     @abc.abstractmethod
-    def itermaps(self):
+    def itermaps(self, context):
         """Yield each template mapping"""
 
     @abc.abstractmethod
@@ -88,7 +88,7 @@
             if i > 0:
                 yield ' '
             yield self.joinfmt(x)
-    def itermaps(self):
+    def itermaps(self, context):
         makemap = self._makemap
         for x in self._values:
             yield makemap(x)
@@ -139,7 +139,7 @@
     def tomap(self):
         return self._makemap(self._key)
 
-    def itermaps(self):
+    def itermaps(self, context):
         yield self.tomap()
 
     def show(self, context, mapping):
@@ -498,7 +498,7 @@
     darg, targ = data
     d = evalrawexp(context, mapping, darg)
     if isinstance(d, wrapped):
-        diter = d.itermaps()
+        diter = d.itermaps(context)
     else:
         try:
             diter = iter(d)