[PATCH 05 of 18 helps-py3] changegroup: move from dict() construction to {} literals

Augie Fackler raf at durin42.com
Wed Mar 12 12:40:39 CDT 2014


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1394644471 14400
#      Wed Mar 12 13:14:31 2014 -0400
# Node ID f8d50add83e18d2f078cb34672cb8198eef91e92
# Parent  2aafd5854243fda6272085846a435e3412e1b9d5
changegroup: move from dict() construction to {} literals

The latter are both faster and more consistent across Python 2 and 3.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -173,7 +173,7 @@
         if not l:
             return {}
         fname = readexactly(self._stream, l)
-        return dict(filename=fname)
+        return {'filename': fname}
 
     def _deltaheader(self, headertuple, prevnode):
         node, p1, p2, cs = headertuple
@@ -191,8 +191,8 @@
         header = struct.unpack(self.deltaheader, headerdata)
         delta = readexactly(self._stream, l - self.deltaheadersize)
         node, p1, p2, deltabase, cs = self._deltaheader(header, prevnode)
-        return dict(node=node, p1=p1, p2=p2, cs=cs,
-                    deltabase=deltabase, delta=delta)
+        return {'node': node, 'p1': p1, 'p2': p2, 'cs': cs,
+                'deltabase': deltabase, 'delta': delta}
 
 class headerlessfixup(object):
     def __init__(self, fh, h):


More information about the Mercurial-devel mailing list