Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotov2server.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 | 8ff1ecfadcd1 |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
963 return nodes | 963 return nodes |
964 | 964 |
965 | 965 |
966 @wireprotocommand(b'branchmap', permission=b'pull') | 966 @wireprotocommand(b'branchmap', permission=b'pull') |
967 def branchmapv2(repo, proto): | 967 def branchmapv2(repo, proto): |
968 yield {encoding.fromlocal(k): v for k, v in repo.branchmap().iteritems()} | 968 yield { |
969 encoding.fromlocal(k): v | |
970 for k, v in pycompat.iteritems(repo.branchmap()) | |
971 } | |
969 | 972 |
970 | 973 |
971 @wireprotocommand(b'capabilities', permission=b'pull') | 974 @wireprotocommand(b'capabilities', permission=b'pull') |
972 def capabilitiesv2(repo, proto): | 975 def capabilitiesv2(repo, proto): |
973 yield _capabilitiesv2(repo, proto) | 976 yield _capabilitiesv2(repo, proto) |
1059 yield extra | 1062 yield extra |
1060 | 1063 |
1061 # If requested, send bookmarks from nodes that didn't have revision | 1064 # If requested, send bookmarks from nodes that didn't have revision |
1062 # data sent so receiver is aware of any bookmark updates. | 1065 # data sent so receiver is aware of any bookmark updates. |
1063 if b'bookmarks' in fields: | 1066 if b'bookmarks' in fields: |
1064 for node, marks in sorted(nodebookmarks.iteritems()): | 1067 for node, marks in sorted(pycompat.iteritems(nodebookmarks)): |
1065 yield { | 1068 yield { |
1066 b'node': node, | 1069 b'node': node, |
1067 b'bookmarks': sorted(marks), | 1070 b'bookmarks': sorted(marks), |
1068 } | 1071 } |
1069 | 1072 |
1377 ) | 1380 ) |
1378 def listkeysv2(repo, proto, namespace): | 1381 def listkeysv2(repo, proto, namespace): |
1379 keys = repo.listkeys(encoding.tolocal(namespace)) | 1382 keys = repo.listkeys(encoding.tolocal(namespace)) |
1380 keys = { | 1383 keys = { |
1381 encoding.fromlocal(k): encoding.fromlocal(v) | 1384 encoding.fromlocal(k): encoding.fromlocal(v) |
1382 for k, v in keys.iteritems() | 1385 for k, v in pycompat.iteritems(keys) |
1383 } | 1386 } |
1384 | 1387 |
1385 yield keys | 1388 yield keys |
1386 | 1389 |
1387 | 1390 |