templater: define interface for objects which act as iterator of mappings
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 Mar 2018 21:21:50 +0900
changeset 37323 8c31b434697f
parent 37322 a67fd1fe5109
child 37324 c2f74b8f6b7f
templater: define interface for objects which act as iterator of mappings
mercurial/templateutil.py
--- a/mercurial/templateutil.py	Wed Apr 04 23:26:49 2018 +0900
+++ b/mercurial/templateutil.py	Sat Mar 17 21:21:50 2018 +0900
@@ -38,6 +38,10 @@
     __metaclass__ = abc.ABCMeta
 
     @abc.abstractmethod
+    def itermaps(self):
+        """Yield each template mapping"""
+
+    @abc.abstractmethod
     def show(self, context, mapping):
         """Return a bytes or (possibly nested) generator of bytes representing
         the underlying object
@@ -493,7 +497,7 @@
 def runmap(context, mapping, data):
     darg, targ = data
     d = evalrawexp(context, mapping, darg)
-    if util.safehasattr(d, 'itermaps'):
+    if isinstance(d, wrapped):
         diter = d.itermaps()
     else:
         try: