Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 43104:74802979dd9d
py3: define and use pycompat.itervalues()
.itervalues() only exists on Python 2. Python 3's equivalent is
.values(). But we don't want to blindly use .values() everywhere
because on Python 2, it will create a list, which will have performance
implications.
This commit introduces pycompat.itervalues() which will call the appropriate
method on the passed object. We update all callers of obj.itervalues()
to pycompat.itervalues(obj) instead.
With this commit, the only source tranforming remaining is for
iteritems(). Victory is near...
Differential Revision: https://phab.mercurial-scm.org/D7013
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Oct 2019 17:59:15 -0400 |
parents | 687b865b95ad |
children | d783f945a701 |
comparison
equal
deleted
inserted
replaced
43103:c95b2f40db7c | 43104:74802979dd9d |
---|---|
89 cl = repo.changelog | 89 cl = repo.changelog |
90 clrev = cl.rev | 90 clrev = cl.rev |
91 clbranchinfo = cl.branchinfo | 91 clbranchinfo = cl.branchinfo |
92 rbheads = [] | 92 rbheads = [] |
93 closed = [] | 93 closed = [] |
94 for bheads in remotebranchmap.itervalues(): | 94 for bheads in pycompat.itervalues(remotebranchmap): |
95 rbheads += bheads | 95 rbheads += bheads |
96 for h in bheads: | 96 for h in bheads: |
97 r = clrev(h) | 97 r = clrev(h) |
98 b, c = clbranchinfo(r) | 98 b, c = clbranchinfo(r) |
99 if c: | 99 if c: |
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() |
353 return self._entries.itervalues() | 353 return pycompat.itervalues(self._entries) |
354 | 354 |
355 def copy(self): | 355 def copy(self): |
356 """return an deep copy of the branchcache object""" | 356 """return an deep copy of the branchcache object""" |
357 return type(self)( | 357 return type(self)( |
358 self._entries, | 358 self._entries, |