diff mercurial/debugcommands.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 e8cf9ad52a78
children defabf63e969
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Sun Oct 06 19:25:18 2019 -0400
+++ b/mercurial/debugcommands.py	Mon Oct 07 00:04:04 2019 -0400
@@ -448,7 +448,7 @@
     b2caps = bundle2.bundle2caps(peer)
     if b2caps:
         ui.writenoi18n(b'Bundle2 capabilities:\n')
-        for key, values in sorted(b2caps.iteritems()):
+        for key, values in sorted(pycompat.iteritems(b2caps)):
             ui.write(b'  %s\n' % key)
             for v in values:
                 ui.write(b'    %s\n' % v)
@@ -870,7 +870,7 @@
         keyfunc = lambda x: (x[1][3], x[0])  # sort by mtime, then by filename
     else:
         keyfunc = None  # sort by filename
-    for file_, ent in sorted(repo.dirstate.iteritems(), key=keyfunc):
+    for file_, ent in sorted(pycompat.iteritems(repo.dirstate), key=keyfunc):
         if ent[3] == -1:
             timestr = b'unset               '
         elif nodates:
@@ -2039,7 +2039,7 @@
     names = set()
     # since we previously only listed open branches, we will handle that
     # specially (after this for loop)
-    for name, ns in repo.names.iteritems():
+    for name, ns in pycompat.iteritems(repo.names):
         if name != b'branches':
             names.update(ns.listnames(repo))
     names.update(
@@ -2268,7 +2268,7 @@
         fullpaths = opts[r'full']
         files, dirs = set(), set()
         adddir, addfile = dirs.add, files.add
-        for f, st in dirstate.iteritems():
+        for f, st in pycompat.iteritems(dirstate):
             if f.startswith(spec) and st[0] in acceptable:
                 if fixpaths:
                     f = f.replace(b'/', pycompat.ossep)
@@ -2454,7 +2454,7 @@
         ui.status(pycompat.bytestr(r) + b'\n')
         return not r
     else:
-        for k, v in sorted(target.listkeys(namespace).iteritems()):
+        for k, v in sorted(pycompat.iteritems(target.listkeys(namespace))):
             ui.write(
                 b"%s\t%s\n" % (stringutil.escapestr(k), stringutil.escapestr(v))
             )
@@ -3608,7 +3608,7 @@
     for opt in cmdutil.remoteopts:
         del opts[opt[1]]
     args = {}
-    for k, v in opts.iteritems():
+    for k, v in pycompat.iteritems(opts):
         if v:
             args[k] = v
     args = pycompat.strkwargs(args)