Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/chgserver.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 | 9f70512ae2cf |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
129 ignored = {b'HG'} | 129 ignored = {b'HG'} |
130 else: | 130 else: |
131 ignored = set() | 131 ignored = set() |
132 envitems = [ | 132 envitems = [ |
133 (k, v) | 133 (k, v) |
134 for k, v in encoding.environ.iteritems() | 134 for k, v in pycompat.iteritems(encoding.environ) |
135 if _envre.match(k) and k not in ignored | 135 if _envre.match(k) and k not in ignored |
136 ] | 136 ] |
137 envhash = _hashlist(sorted(envitems)) | 137 envhash = _hashlist(sorted(envitems)) |
138 return sectionhash[:6] + envhash[:6] | 138 return sectionhash[:6] + envhash[:6] |
139 | 139 |
315 self.out = out | 315 self.out = out |
316 self.channel = channel | 316 self.channel = channel |
317 | 317 |
318 def __call__(self, cmd, environ, cwd=None, type=b'system', cmdtable=None): | 318 def __call__(self, cmd, environ, cwd=None, type=b'system', cmdtable=None): |
319 args = [type, procutil.quotecommand(cmd), os.path.abspath(cwd or b'.')] | 319 args = [type, procutil.quotecommand(cmd), os.path.abspath(cwd or b'.')] |
320 args.extend(b'%s=%s' % (k, v) for k, v in environ.iteritems()) | 320 args.extend(b'%s=%s' % (k, v) for k, v in pycompat.iteritems(environ)) |
321 data = b'\0'.join(args) | 321 data = b'\0'.join(args) |
322 self.out.write(struct.pack(b'>cI', self.channel, len(data))) | 322 self.out.write(struct.pack(b'>cI', self.channel, len(data))) |
323 self.out.write(data) | 323 self.out.write(data) |
324 self.out.flush() | 324 self.out.flush() |
325 | 325 |