diff mercurial/templateutil.py @ 43106:d783f945a701

py3: finish porting iteritems() to pycompat and remove source transformer This commit finishes porting .iteritems() to pycompat.iteritems() for the mercurial package. The translation of .iteritems() to .items() was the last conversion performed by the source transformer. With the porting to pycompat complete, we no longer have a need for the source transformer. So the source transformer has been removed. Good riddance! The code base is now compatible with Python 2 and Python 3. For the record, as the person who introduced the source transformer, it brings me joy to delete it. It accomplished its goal to facilitate a port to Python 3 without overly burdening people on some painful low-level differences between Python 2 and 3. It is unfortunate we still have to wallpaper over many differences with the pycompat shim. But it is what it is. Differential Revision: https://phab.mercurial-scm.org/D7015
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 07 Oct 2019 00:04:04 -0400
parents c59eb1560c44
children 3e57809d3251
line wrap: on
line diff
--- a/mercurial/templateutil.py	Sun Oct 06 19:25:18 2019 -0400
+++ b/mercurial/templateutil.py	Mon Oct 07 00:04:04 2019 -0400
@@ -308,7 +308,7 @@
         if util.safehasattr(self._values, b'get'):
             values = {
                 k: v
-                for k, v in self._values.iteritems()
+                for k, v in pycompat.iteritems(self._values)
                 if select(self._wrapvalue(k, v))
             }
         else:
@@ -341,7 +341,8 @@
         xs = self._values
         if util.safehasattr(xs, b'get'):
             return {
-                k: unwrapvalue(context, mapping, v) for k, v in xs.iteritems()
+                k: unwrapvalue(context, mapping, v)
+                for k, v in pycompat.iteritems(xs)
             }
         return [unwrapvalue(context, mapping, x) for x in xs]
 
@@ -461,7 +462,7 @@
             items.append(
                 {
                     k: unwrapvalue(context, lm, v)
-                    for k, v in nm.iteritems()
+                    for k, v in pycompat.iteritems(nm)
                     if k not in knownres
                 }
             )
@@ -639,7 +640,7 @@
     This exists for backward compatibility with the old-style template. Use
     hybriddict() for new template keywords.
     """
-    c = [{key: k, value: v} for k, v in data.iteritems()]
+    c = [{key: k, value: v} for k, v in pycompat.iteritems(data)]
     f = _showcompatlist(context, mapping, name, c, plural, separator)
     return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)