Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pycompat.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 | 74802979dd9d |
children | d783f945a701 |
comparison
equal
deleted
inserted
replaced
43104:74802979dd9d | 43105:649d3ac37a12 |
---|---|
335 Python 3 compatibility as shelx.split() don't accept bytes on Python 3. | 335 Python 3 compatibility as shelx.split() don't accept bytes on Python 3. |
336 """ | 336 """ |
337 ret = shlex.split(s.decode('latin-1'), comments, posix) | 337 ret = shlex.split(s.decode('latin-1'), comments, posix) |
338 return [a.encode('latin-1') for a in ret] | 338 return [a.encode('latin-1') for a in ret] |
339 | 339 |
340 iteritems = lambda x: x.items() | |
340 itervalues = lambda x: x.values() | 341 itervalues = lambda x: x.values() |
341 | 342 |
342 else: | 343 else: |
343 import cStringIO | 344 import cStringIO |
344 | 345 |
412 maplist = map | 413 maplist = map |
413 rangelist = range | 414 rangelist = range |
414 ziplist = zip | 415 ziplist = zip |
415 rawinput = raw_input | 416 rawinput = raw_input |
416 getargspec = inspect.getargspec | 417 getargspec = inspect.getargspec |
418 iteritems = lambda x: x.iteritems() | |
417 itervalues = lambda x: x.itervalues() | 419 itervalues = lambda x: x.itervalues() |
418 | 420 |
419 isjython = sysplatform.startswith(b'java') | 421 isjython = sysplatform.startswith(b'java') |
420 | 422 |
421 isdarwin = sysplatform.startswith(b'darwin') | 423 isdarwin = sysplatform.startswith(b'darwin') |