Mercurial > hg
changeset 20672:05e58b08fdfe
synthrepo: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 12 Mar 2014 13:12:26 -0400 |
parents | 5442cab57b09 |
children | 37cde285b89c |
files | contrib/synthrepo.py |
diffstat | 1 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/synthrepo.py Wed Mar 12 13:00:51 2014 -0400 +++ b/contrib/synthrepo.py Wed Mar 12 13:12:26 2014 -0400 @@ -152,7 +152,7 @@ if lastctx.rev() != nullrev: interarrival[roundto(ctx.date()[0] - lastctx.date()[0], 300)] += 1 diff = sum((d.splitlines() - for d in ctx.diff(pctx, opts=dict(git=True))), []) + for d in ctx.diff(pctx, opts={'git': True})), []) fileadds, diradds, fileremoves, filechanges = 0, 0, 0, 0 for filename, mar, lineadd, lineremove, binary in parsegitdiff(diff): if binary: @@ -189,21 +189,21 @@ def pronk(d): return sorted(d.iteritems(), key=lambda x: x[1], reverse=True) - json.dump(dict(revs=len(revs), - lineschanged=pronk(lineschanged), - children=pronk(invchildren), - fileschanged=pronk(fileschanged), - filesadded=pronk(filesadded), - linesinfilesadded=pronk(linesinfilesadded), - dirsadded=pronk(dirsadded), - filesremoved=pronk(filesremoved), - linelengths=pronk(linelengths), - parents=pronk(parents), - p1distance=pronk(p1distance), - p2distance=pronk(p2distance), - interarrival=pronk(interarrival), - tzoffset=pronk(tzoffset), - ), + json.dump({'revs': len(revs), + 'lineschanged': pronk(lineschanged), + 'children': pronk(invchildren), + 'fileschanged': pronk(fileschanged), + 'filesadded': pronk(filesadded), + 'linesinfilesadded': pronk(linesinfilesadded), + 'dirsadded': pronk(dirsadded), + 'filesremoved': pronk(filesremoved), + 'linelengths': pronk(linelengths), + 'parents': pronk(parents), + 'p1distance': pronk(p1distance), + 'p2distance': pronk(p2distance), + 'interarrival': pronk(interarrival), + 'tzoffset': pronk(tzoffset), + }, fp) fp.close()