Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.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 | c95b2f40db7c |
children | 8ff1ecfadcd1 |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
1263 | 1263 |
1264 if pycompat.ispypy: | 1264 if pycompat.ispypy: |
1265 # __setitem__() isn't called as of PyPy 5.8.0 | 1265 # __setitem__() isn't called as of PyPy 5.8.0 |
1266 def update(self, src): | 1266 def update(self, src): |
1267 if isinstance(src, dict): | 1267 if isinstance(src, dict): |
1268 src = src.iteritems() | 1268 src = pycompat.iteritems(src) |
1269 for k, v in src: | 1269 for k, v in src: |
1270 self[k] = v | 1270 self[k] = v |
1271 | 1271 |
1272 | 1272 |
1273 class cowdict(cow, dict): | 1273 class cowdict(cow, dict): |
3499 | 3499 |
3500 def __init__(self, map, skip=None): | 3500 def __init__(self, map, skip=None): |
3501 self._dirs = {} | 3501 self._dirs = {} |
3502 addpath = self.addpath | 3502 addpath = self.addpath |
3503 if isinstance(map, dict) and skip is not None: | 3503 if isinstance(map, dict) and skip is not None: |
3504 for f, s in map.iteritems(): | 3504 for f, s in pycompat.iteritems(map): |
3505 if s[0] != skip: | 3505 if s[0] != skip: |
3506 addpath(f) | 3506 addpath(f) |
3507 elif skip is not None: | 3507 elif skip is not None: |
3508 raise error.ProgrammingError( | 3508 raise error.ProgrammingError( |
3509 b"skip character is only supported " b"with a dict source" | 3509 b"skip character is only supported " b"with a dict source" |