diff hgext/absorb.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 687b865b95ad
children 4aa72cdf616f
line wrap: on
line diff
--- a/hgext/absorb.py	Sun Oct 06 17:59:15 2019 -0400
+++ b/hgext/absorb.py	Sun Oct 06 19:25:18 2019 -0400
@@ -726,7 +726,7 @@
 
     def apply(self):
         """apply fixups to individual filefixupstates"""
-        for path, state in self.fixupmap.iteritems():
+        for path, state in pycompat.iteritems(self.fixupmap):
             if self.ui.debugflag:
                 self.ui.write(_(b'applying fixups to %s\n') % path)
             state.apply()
@@ -736,7 +736,7 @@
         """-> {path: chunkstats}. collect chunkstats from filefixupstates"""
         return dict(
             (path, state.chunkstats)
-            for path, state in self.fixupmap.iteritems()
+            for path, state in pycompat.iteritems(self.fixupmap)
         )
 
     def commit(self):
@@ -755,7 +755,7 @@
         chunkstats = self.chunkstats
         if ui.verbose:
             # chunkstats for each file
-            for path, stat in chunkstats.iteritems():
+            for path, stat in pycompat.iteritems(chunkstats):
                 if stat[0]:
                     ui.write(
                         _(b'%s: %d of %d chunk(s) applied\n')
@@ -831,7 +831,7 @@
         repo = self.repo
         needupdate = [
             (name, self.replacemap[hsh])
-            for name, hsh in repo._bookmarks.iteritems()
+            for name, hsh in pycompat.iteritems(repo._bookmarks)
             if hsh in self.replacemap
         ]
         changes = []
@@ -890,7 +890,7 @@
         # ctx changes more files (not a subset of memworkingcopy)
         if not set(ctx.files()).issubset(set(memworkingcopy)):
             return False
-        for path, content in memworkingcopy.iteritems():
+        for path, content in pycompat.iteritems(memworkingcopy):
             if path not in pctx or path not in ctx:
                 return False
             fctx = ctx[path]
@@ -922,7 +922,7 @@
     def _cleanupoldcommits(self):
         replacements = {
             k: ([v] if v is not None else [])
-            for k, v in self.replacemap.iteritems()
+            for k, v in pycompat.iteritems(self.replacemap)
         }
         if replacements:
             scmutil.cleanupnodes(
@@ -968,7 +968,7 @@
         if not path or not info:
             continue
         patchmap[path].append(info)
-    for path, patches in patchmap.iteritems():
+    for path, patches in pycompat.iteritems(patchmap):
         if path not in ctx or not patches:
             continue
         patches.sort(reverse=True)