comparison contrib/synthrepo.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 2372284d9457
children 89a2afe31e82
comparison
equal deleted inserted replaced
43103:c95b2f40db7c 43104:74802979dd9d
211 ) 211 )
212 fileadds, diradds, fileremoves, filechanges = 0, 0, 0, 0 212 fileadds, diradds, fileremoves, filechanges = 0, 0, 0, 0
213 for filename, mar, lineadd, lineremove, isbin in parsegitdiff(diff): 213 for filename, mar, lineadd, lineremove, isbin in parsegitdiff(diff):
214 if isbin: 214 if isbin:
215 continue 215 continue
216 added = sum(lineadd.itervalues(), 0) 216 added = sum(pycompat.itervalues(lineadd), 0)
217 if mar == 'm': 217 if mar == 'm':
218 if added and lineremove: 218 if added and lineremove:
219 lineschanged[ 219 lineschanged[
220 roundto(added, 5), roundto(lineremove, 5) 220 roundto(added, 5), roundto(lineremove, 5)
221 ] += 1 221 ] += 1