comparison hgext/fastannotate/protocol.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 eef9a2d67051
children b6b696442a4d
comparison
equal deleted inserted replaced
43104:74802979dd9d 43105:649d3ac37a12
13 from mercurial.pycompat import open 13 from mercurial.pycompat import open
14 from mercurial import ( 14 from mercurial import (
15 error, 15 error,
16 extensions, 16 extensions,
17 hg, 17 hg,
18 pycompat,
18 util, 19 util,
19 wireprotov1peer, 20 wireprotov1peer,
20 wireprotov1server, 21 wireprotov1server,
21 ) 22 )
22 from . import context 23 from . import context
186 ) 187 )
187 188
188 for result in results: 189 for result in results:
189 r = result.result() 190 r = result.result()
190 # TODO: pconvert these paths on the server? 191 # TODO: pconvert these paths on the server?
191 r = {util.pconvert(p): v for p, v in r.iteritems()} 192 r = {util.pconvert(p): v for p, v in pycompat.iteritems(r)}
192 for path in sorted(r): 193 for path in sorted(r):
193 # ignore malicious paths 194 # ignore malicious paths
194 if not path.startswith(b'fastannotate/') or b'/../' in ( 195 if not path.startswith(b'fastannotate/') or b'/../' in (
195 path + b'/' 196 path + b'/'
196 ): 197 ):