Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.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 | c59eb1560c44 |
children | 54e943b28101 |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
133 for subpath in ctx2.substate: | 133 for subpath in ctx2.substate: |
134 if subpath not in ctx1.substate: | 134 if subpath not in ctx1.substate: |
135 del subpaths[subpath] | 135 del subpaths[subpath] |
136 missing.add(subpath) | 136 missing.add(subpath) |
137 | 137 |
138 for subpath, ctx in sorted(subpaths.iteritems()): | 138 for subpath, ctx in sorted(pycompat.iteritems(subpaths)): |
139 yield subpath, ctx.sub(subpath) | 139 yield subpath, ctx.sub(subpath) |
140 | 140 |
141 # Yield an empty subrepo based on ctx1 for anything only in ctx2. That way, | 141 # Yield an empty subrepo based on ctx1 for anything only in ctx2. That way, |
142 # status and diff will have an accurate result when it does | 142 # status and diff will have an accurate result when it does |
143 # 'sub.{status|diff}(rev2)'. Otherwise, the ctx2 subrepo is compared | 143 # 'sub.{status|diff}(rev2)'. Otherwise, the ctx2 subrepo is compared |
1296 subrepos=sorted(ctx.substate), | 1296 subrepos=sorted(ctx.substate), |
1297 unknown=True, | 1297 unknown=True, |
1298 ignored=False, | 1298 ignored=False, |
1299 full=False, | 1299 full=False, |
1300 ) | 1300 ) |
1301 for abs, st in walkresults.iteritems(): | 1301 for abs, st in pycompat.iteritems(walkresults): |
1302 dstate = dirstate[abs] | 1302 dstate = dirstate[abs] |
1303 if dstate == b'?' and audit_path.check(abs): | 1303 if dstate == b'?' and audit_path.check(abs): |
1304 unknown.append(abs) | 1304 unknown.append(abs) |
1305 elif dstate != b'r' and not st: | 1305 elif dstate != b'r' and not st: |
1306 deleted.append(abs) | 1306 deleted.append(abs) |
1343 and the files in renames as copied.''' | 1343 and the files in renames as copied.''' |
1344 wctx = repo[None] | 1344 wctx = repo[None] |
1345 with repo.wlock(): | 1345 with repo.wlock(): |
1346 wctx.forget(deleted) | 1346 wctx.forget(deleted) |
1347 wctx.add(unknown) | 1347 wctx.add(unknown) |
1348 for new, old in renames.iteritems(): | 1348 for new, old in pycompat.iteritems(renames): |
1349 wctx.copy(old, new) | 1349 wctx.copy(old, new) |
1350 | 1350 |
1351 | 1351 |
1352 def getrenamedfn(repo, endrev=None): | 1352 def getrenamedfn(repo, endrev=None): |
1353 if copiesmod.usechangesetcentricalgo(repo): | 1353 if copiesmod.usechangesetcentricalgo(repo): |
1479 | 1479 |
1480 # Merge old parent and old working dir copies | 1480 # Merge old parent and old working dir copies |
1481 oldcopies = copiesmod.pathcopies(newctx, oldctx, match) | 1481 oldcopies = copiesmod.pathcopies(newctx, oldctx, match) |
1482 oldcopies.update(copies) | 1482 oldcopies.update(copies) |
1483 copies = dict( | 1483 copies = dict( |
1484 (dst, oldcopies.get(src, src)) for dst, src in oldcopies.iteritems() | 1484 (dst, oldcopies.get(src, src)) |
1485 for dst, src in pycompat.iteritems(oldcopies) | |
1485 ) | 1486 ) |
1486 # Adjust the dirstate copies | 1487 # Adjust the dirstate copies |
1487 for dst, src in copies.iteritems(): | 1488 for dst, src in pycompat.iteritems(copies): |
1488 if src not in newctx or dst in newctx or ds[dst] != b'a': | 1489 if src not in newctx or dst in newctx or ds[dst] != b'a': |
1489 src = None | 1490 src = None |
1490 ds.copy(src, dst) | 1491 ds.copy(src, dst) |
1491 | 1492 |
1492 | 1493 |
2068 phasetracking = tr.changes.get(b'phases', {}) | 2069 phasetracking = tr.changes.get(b'phases', {}) |
2069 if not phasetracking: | 2070 if not phasetracking: |
2070 return | 2071 return |
2071 published = [ | 2072 published = [ |
2072 rev | 2073 rev |
2073 for rev, (old, new) in phasetracking.iteritems() | 2074 for rev, (old, new) in pycompat.iteritems(phasetracking) |
2074 if new == phases.public and rev < origrepolen | 2075 if new == phases.public and rev < origrepolen |
2075 ] | 2076 ] |
2076 if not published: | 2077 if not published: |
2077 return | 2078 return |
2078 repo.ui.status( | 2079 repo.ui.status( |