diff hgext/remotefilelog/repack.py @ 43105:649d3ac37a12

py3: define and use pycompat.iteritems() for hgext/ .iteritems() -> .items() is the last source transform being performed. But it is also the most widely used. This commit adds a pycompat.iteritems symbol and imports it in place of .iteritems() for usage in hgext/. I chose to stop at just hgext/ because the patch will be large and it is an easy boundary to stop at since we can disable source transformation on a per-package basis. There are places where the type does implement items() and we could call items() directly. However, this would require critical thought and I thought it would be easier to just blindly change the code. We know which call sites need to be audited in the future because they have "pycompat.iteritems." With this change, we no longer perform source transformation on hgext! Differential Revision: https://phab.mercurial-scm.org/D7014
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 06 Oct 2019 19:25:18 -0400
parents 74802979dd9d
children 4aa72cdf616f
line wrap: on
line diff
--- a/hgext/remotefilelog/repack.py	Sun Oct 06 17:59:15 2019 -0400
+++ b/hgext/remotefilelog/repack.py	Sun Oct 06 19:25:18 2019 -0400
@@ -491,12 +491,12 @@
         if type(m) is dict:
             # m is a result of diff of two manifests and is a dictionary that
             # maps filename to ((newnode, newflag), (oldnode, oldflag)) tuple
-            for filename, diff in m.iteritems():
+            for filename, diff in pycompat.iteritems(m):
                 if diff[0][0] is not None:
                     keepkeys.add(keyfn(filename, diff[0][0]))
         else:
             # m is a manifest object
-            for filename, filenode in m.iteritems():
+            for filename, filenode in pycompat.iteritems(m):
                 keepkeys.add(keyfn(filename, filenode))
 
     return keepkeys
@@ -606,7 +606,7 @@
         repackprogress = ui.makeprogress(
             _(b"repacking data"), unit=self.unit, total=len(byfile)
         )
-        for filename, entries in sorted(byfile.iteritems()):
+        for filename, entries in sorted(pycompat.iteritems(byfile)):
             repackprogress.update(count)
 
             ancestors = {}
@@ -760,7 +760,7 @@
         progress = ui.makeprogress(
             _(b"repacking history"), unit=self.unit, total=len(byfile)
         )
-        for filename, entries in sorted(byfile.iteritems()):
+        for filename, entries in sorted(pycompat.iteritems(byfile)):
             ancestors = {}
             nodes = list(node for node in entries)