Mercurial > hg
comparison mercurial/branchmap.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 | 74802979dd9d |
children | 1a47fe4bc154 |
comparison
equal
deleted
inserted
replaced
43105:649d3ac37a12 | 43106:d783f945a701 |
---|---|
226 def __contains__(self, key): | 226 def __contains__(self, key): |
227 self._verifybranch(key) | 227 self._verifybranch(key) |
228 return key in self._entries | 228 return key in self._entries |
229 | 229 |
230 def iteritems(self): | 230 def iteritems(self): |
231 for k, v in self._entries.iteritems(): | 231 for k, v in pycompat.iteritems(self._entries): |
232 self._verifybranch(k) | 232 self._verifybranch(k) |
233 yield k, v | 233 yield k, v |
234 | 234 |
235 items = iteritems | 235 items = iteritems |
236 | 236 |
342 if not closed: | 342 if not closed: |
343 heads = list(self.iteropen(heads)) | 343 heads = list(self.iteropen(heads)) |
344 return heads | 344 return heads |
345 | 345 |
346 def iterbranches(self): | 346 def iterbranches(self): |
347 for bn, heads in self.iteritems(): | 347 for bn, heads in pycompat.iteritems(self): |
348 yield (bn, heads) + self._branchtip(heads) | 348 yield (bn, heads) + self._branchtip(heads) |
349 | 349 |
350 def iterheads(self): | 350 def iterheads(self): |
351 """ returns all the heads """ | 351 """ returns all the heads """ |
352 self._verifyall() | 352 self._verifyall() |
368 cachekey = [hex(self.tipnode), b'%d' % self.tiprev] | 368 cachekey = [hex(self.tipnode), b'%d' % self.tiprev] |
369 if self.filteredhash is not None: | 369 if self.filteredhash is not None: |
370 cachekey.append(hex(self.filteredhash)) | 370 cachekey.append(hex(self.filteredhash)) |
371 f.write(b" ".join(cachekey) + b'\n') | 371 f.write(b" ".join(cachekey) + b'\n') |
372 nodecount = 0 | 372 nodecount = 0 |
373 for label, nodes in sorted(self._entries.iteritems()): | 373 for label, nodes in sorted(pycompat.iteritems(self._entries)): |
374 label = encoding.fromlocal(label) | 374 label = encoding.fromlocal(label) |
375 for node in nodes: | 375 for node in nodes: |
376 nodecount += 1 | 376 nodecount += 1 |
377 if node in self._closednodes: | 377 if node in self._closednodes: |
378 state = b'c' | 378 state = b'c' |
418 ntiprev = self.tiprev | 418 ntiprev = self.tiprev |
419 | 419 |
420 # if older branchheads are reachable from new ones, they aren't | 420 # if older branchheads are reachable from new ones, they aren't |
421 # really branchheads. Note checking parents is insufficient: | 421 # really branchheads. Note checking parents is insufficient: |
422 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) | 422 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
423 for branch, newheadrevs in newbranches.iteritems(): | 423 for branch, newheadrevs in pycompat.iteritems(newbranches): |
424 bheads = self._entries.setdefault(branch, []) | 424 bheads = self._entries.setdefault(branch, []) |
425 bheadset = set(cl.rev(node) for node in bheads) | 425 bheadset = set(cl.rev(node) for node in bheads) |
426 | 426 |
427 # This have been tested True on all internal usage of this function. | 427 # This have been tested True on all internal usage of this function. |
428 # run it again in case of doubt | 428 # run it again in case of doubt |