Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotov1server.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 | 8ff1ecfadcd1 |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
241 | 241 |
242 @wireprotocommand(b'branchmap', permission=b'pull') | 242 @wireprotocommand(b'branchmap', permission=b'pull') |
243 def branchmap(repo, proto): | 243 def branchmap(repo, proto): |
244 branchmap = repo.branchmap() | 244 branchmap = repo.branchmap() |
245 heads = [] | 245 heads = [] |
246 for branch, nodes in branchmap.iteritems(): | 246 for branch, nodes in pycompat.iteritems(branchmap): |
247 branchname = urlreq.quote(encoding.fromlocal(branch)) | 247 branchname = urlreq.quote(encoding.fromlocal(branch)) |
248 branchnodes = wireprototypes.encodelist(nodes) | 248 branchnodes = wireprototypes.encodelist(nodes) |
249 heads.append(b'%s %s' % (branchname, branchnodes)) | 249 heads.append(b'%s %s' % (branchname, branchnodes)) |
250 | 250 |
251 return wireprototypes.bytesresponse(b'\n'.join(heads)) | 251 return wireprototypes.bytesresponse(b'\n'.join(heads)) |
438 @wireprotocommand(b'getbundle', b'*', permission=b'pull') | 438 @wireprotocommand(b'getbundle', b'*', permission=b'pull') |
439 def getbundle(repo, proto, others): | 439 def getbundle(repo, proto, others): |
440 opts = options( | 440 opts = options( |
441 b'getbundle', wireprototypes.GETBUNDLE_ARGUMENTS.keys(), others | 441 b'getbundle', wireprototypes.GETBUNDLE_ARGUMENTS.keys(), others |
442 ) | 442 ) |
443 for k, v in opts.iteritems(): | 443 for k, v in pycompat.iteritems(opts): |
444 keytype = wireprototypes.GETBUNDLE_ARGUMENTS[k] | 444 keytype = wireprototypes.GETBUNDLE_ARGUMENTS[k] |
445 if keytype == b'nodes': | 445 if keytype == b'nodes': |
446 opts[k] = wireprototypes.decodelist(v) | 446 opts[k] = wireprototypes.decodelist(v) |
447 elif keytype == b'csv': | 447 elif keytype == b'csv': |
448 opts[k] = list(v.split(b',')) | 448 opts[k] = list(v.split(b',')) |