diff mercurial/dirstate.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 1f339b503a40
children 8ff1ecfadcd1
line wrap: on
line diff
--- a/mercurial/dirstate.py	Sun Oct 06 19:25:18 2019 -0400
+++ b/mercurial/dirstate.py	Mon Oct 07 00:04:04 2019 -0400
@@ -282,7 +282,7 @@
         return iter(sorted(self._map))
 
     def items(self):
-        return self._map.iteritems()
+        return pycompat.iteritems(self._map)
 
     iteritems = items
 
@@ -670,7 +670,9 @@
     def _writedirstate(self, st):
         # notify callbacks about parents change
         if self._origpl is not None and self._origpl != self._pl:
-            for c, callback in sorted(self._plchangecallbacks.iteritems()):
+            for c, callback in sorted(
+                pycompat.iteritems(self._plchangecallbacks)
+            ):
                 callback(self, self._origpl, self._pl)
             self._origpl = None
         # use the modification time of the newly created temporary file as the
@@ -682,7 +684,7 @@
         delaywrite = self._ui.configint(b'debug', b'dirstate.delaywrite')
         if delaywrite > 0:
             # do we have any files to delay for?
-            items = self._map.iteritems()
+            items = pycompat.iteritems(self._map)
             for f, e in items:
                 if e[0] == b'n' and e[3] == now:
                     import time  # to avoid useless import
@@ -863,7 +865,7 @@
         if match.isexact() and self._checkcase:
             normed = {}
 
-            for f, st in results.iteritems():
+            for f, st in pycompat.iteritems(results):
                 if st is None:
                     continue
 
@@ -876,7 +878,7 @@
 
                 paths.add(f)
 
-            for norm, paths in normed.iteritems():
+            for norm, paths in pycompat.iteritems(normed):
                 if len(paths) > 1:
                     for path in paths:
                         folded = self._discoverpath(
@@ -1111,9 +1113,9 @@
         # - match.traversedir does something, because match.traversedir should
         #   be called for every dir in the working dir
         full = listclean or match.traversedir is not None
-        for fn, st in self.walk(
-            match, subrepos, listunknown, listignored, full=full
-        ).iteritems():
+        for fn, st in pycompat.iteritems(
+            self.walk(match, subrepos, listunknown, listignored, full=full)
+        ):
             if not dcontains(fn):
                 if (listignored or mexact(fn)) and dirignore(fn):
                     if listignored:
@@ -1324,7 +1326,7 @@
         util.clearcachedproperty(self, b"otherparentset")
 
     def items(self):
-        return self._map.iteritems()
+        return pycompat.iteritems(self._map)
 
     # forward for python2,3 compat
     iteritems = items
@@ -1412,7 +1414,7 @@
         except AttributeError:
             nonnorm = set()
             otherparent = set()
-            for fname, e in self._map.iteritems():
+            for fname, e in pycompat.iteritems(self._map):
                 if e[0] != b'n' or e[3] == -1:
                     nonnorm.add(fname)
                 if e[0] == b'n' and e[2] == -2:
@@ -1435,7 +1437,7 @@
 
         f = {}
         normcase = util.normcase
-        for name, s in self._map.iteritems():
+        for name, s in pycompat.iteritems(self._map):
             if s[0] != b'r':
                 f[normcase(name)] = name
         f[b'.'] = b'.'  # prevents useless util.fspath() invocation