diff mercurial/bookmarks.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 8ff1ecfadcd1
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Sun Oct 06 19:25:18 2019 -0400
+++ b/mercurial/bookmarks.py	Mon Oct 07 00:04:04 2019 -0400
@@ -137,7 +137,7 @@
         return iter(self._refmap)
 
     def iteritems(self):
-        return self._refmap.iteritems()
+        return pycompat.iteritems(self._refmap)
 
     def items(self):
         return self._refmap.items()
@@ -245,7 +245,7 @@
         self._aclean = True
 
     def _write(self, fp):
-        for name, node in sorted(self._refmap.iteritems()):
+        for name, node in sorted(pycompat.iteritems(self._refmap)):
             fp.write(b"%s %s\n" % (hex(node), encoding.fromlocal(name)))
         self._clean = True
         self._repo.invalidatevolatilesets()
@@ -413,7 +413,7 @@
         )
     name = repo._activebookmark.split(b'@', 1)[0]
     heads = []
-    for mark, n in repo._bookmarks.iteritems():
+    for mark, n in pycompat.iteritems(repo._bookmarks):
         if mark.split(b'@', 1)[0] == name:
             heads.append(n)
     return heads
@@ -467,7 +467,7 @@
     marks = getattr(repo, '_bookmarks', {})
 
     hasnode = repo.changelog.hasnode
-    for k, v in marks.iteritems():
+    for k, v in pycompat.iteritems(marks):
         # don't expose local divergent bookmarks
         if hasnode(v) and (b'@' not in k or k.endswith(b'@')):
             yield k, v
@@ -999,7 +999,7 @@
     hexfn = fm.hexfunc
     if len(bmarks) == 0 and fm.isplain():
         ui.status(_(b"no bookmarks set\n"))
-    for bmark, (n, prefix, label) in sorted(bmarks.iteritems()):
+    for bmark, (n, prefix, label) in sorted(pycompat.iteritems(bmarks)):
         fm.startitem()
         fm.context(repo=repo)
         if not ui.quiet: