comparison mercurial/branchmap.py @ 48913:f254fc73d956

global: bulk replace simple pycompat.iteritems(x) with x.items() pycompat.iteritems() just calls .items(). This commit applies a regular expression search and replace to convert simple instances of pycompat.iteritems() with .items(). There are still a handful of calls to pycompat.iteritems() remaining. But these all have more complicated expressions that I wasn't comfortable performing an automated replace on. In addition, some simple replacements were withheld because they broke pytype. These will be handled by their own changesets. Differential Revision: https://phab.mercurial-scm.org/D12318
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 03 Mar 2022 18:28:30 -0800
parents 6000f5b25c9b
children 2cce2fa5bcf7
comparison
equal deleted inserted replaced
48912:a0674e916fb6 48913:f254fc73d956
268 def __contains__(self, key): 268 def __contains__(self, key):
269 self._verifybranch(key) 269 self._verifybranch(key)
270 return key in self._entries 270 return key in self._entries
271 271
272 def iteritems(self): 272 def iteritems(self):
273 for k, v in pycompat.iteritems(self._entries): 273 for k, v in self._entries.items():
274 self._verifybranch(k) 274 self._verifybranch(k)
275 yield k, v 275 yield k, v
276 276
277 items = iteritems 277 items = iteritems
278 278
398 if not closed: 398 if not closed:
399 heads = list(self.iteropen(heads)) 399 heads = list(self.iteropen(heads))
400 return heads 400 return heads
401 401
402 def iterbranches(self): 402 def iterbranches(self):
403 for bn, heads in pycompat.iteritems(self): 403 for bn, heads in self.items():
404 yield (bn, heads) + self._branchtip(heads) 404 yield (bn, heads) + self._branchtip(heads)
405 405
406 def iterheads(self): 406 def iterheads(self):
407 """returns all the heads""" 407 """returns all the heads"""
408 self._verifyall() 408 self._verifyall()
432 cachekey = [hex(self.tipnode), b'%d' % self.tiprev] 432 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
433 if self.filteredhash is not None: 433 if self.filteredhash is not None:
434 cachekey.append(hex(self.filteredhash)) 434 cachekey.append(hex(self.filteredhash))
435 f.write(b" ".join(cachekey) + b'\n') 435 f.write(b" ".join(cachekey) + b'\n')
436 nodecount = 0 436 nodecount = 0
437 for label, nodes in sorted(pycompat.iteritems(self._entries)): 437 for label, nodes in sorted(self._entries.items()):
438 label = encoding.fromlocal(label) 438 label = encoding.fromlocal(label)
439 for node in nodes: 439 for node in nodes:
440 nodecount += 1 440 nodecount += 1
441 if node in self._closednodes: 441 if node in self._closednodes:
442 state = b'c' 442 state = b'c'
488 parentrevs = repo.unfiltered().changelog.parentrevs 488 parentrevs = repo.unfiltered().changelog.parentrevs
489 489
490 # Faster than using ctx.obsolete() 490 # Faster than using ctx.obsolete()
491 obsrevs = obsolete.getrevs(repo, b'obsolete') 491 obsrevs = obsolete.getrevs(repo, b'obsolete')
492 492
493 for branch, newheadrevs in pycompat.iteritems(newbranches): 493 for branch, newheadrevs in newbranches.items():
494 # For every branch, compute the new branchheads. 494 # For every branch, compute the new branchheads.
495 # A branchhead is a revision such that no descendant is on 495 # A branchhead is a revision such that no descendant is on
496 # the same branch. 496 # the same branch.
497 # 497 #
498 # The branchheads are computed iteratively in revision order. 498 # The branchheads are computed iteratively in revision order.