comparison mercurial/logexchange.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 687b865b95ad
children 89a2afe31e82
comparison
equal deleted inserted replaced
43105:649d3ac37a12 43106:d783f945a701
9 from __future__ import absolute_import 9 from __future__ import absolute_import
10 10
11 from .node import hex 11 from .node import hex
12 12
13 from . import ( 13 from . import (
14 pycompat,
14 util, 15 util,
15 vfs as vfsmod, 16 vfs as vfsmod,
16 ) 17 )
17 18
18 # directory name in .hg/ in which remotenames files will be present 19 # directory name in .hg/ in which remotenames files will be present
72 # re-save the data from a different remote than this one. 73 # re-save the data from a different remote than this one.
73 for node, oldpath, rname in sorted(olddata): 74 for node, oldpath, rname in sorted(olddata):
74 if oldpath != remotepath: 75 if oldpath != remotepath:
75 f.write(b'%s\0%s\0%s\n' % (node, oldpath, rname)) 76 f.write(b'%s\0%s\0%s\n' % (node, oldpath, rname))
76 77
77 for name, node in sorted(names.iteritems()): 78 for name, node in sorted(pycompat.iteritems(names)):
78 if nametype == b"branches": 79 if nametype == b"branches":
79 for n in node: 80 for n in node:
80 f.write(b'%s\0%s\0%s\n' % (n, remotepath, name)) 81 f.write(b'%s\0%s\0%s\n' % (n, remotepath, name))
81 elif nametype == b"bookmarks": 82 elif nametype == b"bookmarks":
82 if node: 83 if node:
151 repo = localrepo.unfiltered() 152 repo = localrepo.unfiltered()
152 153
153 with remoterepo.commandexecutor() as e: 154 with remoterepo.commandexecutor() as e:
154 branchmap = e.callcommand(b'branchmap', {}).result() 155 branchmap = e.callcommand(b'branchmap', {}).result()
155 156
156 for branch, nodes in branchmap.iteritems(): 157 for branch, nodes in pycompat.iteritems(branchmap):
157 bmap[branch] = [] 158 bmap[branch] = []
158 for node in nodes: 159 for node in nodes:
159 if node in repo and not repo[node].obsolete(): 160 if node in repo and not repo[node].obsolete():
160 bmap[branch].append(hex(node)) 161 bmap[branch].append(hex(node))
161 162