# HG changeset patch # User Yuya Nishihara # Date 1521289310 -32400 # Node ID 8c31b434697f7e576d3b9a11d6facb6af1d12d92 # Parent a67fd1fe510984f91a81df2c114e150442818068 templater: define interface for objects which act as iterator of mappings diff -r a67fd1fe5109 -r 8c31b434697f 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: