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

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


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1394644422 14400
#      Wed Mar 12 13:13:42 2014 -0400
# Node ID 2aafd5854243fda6272085846a435e3412e1b9d5
# Parent  37cde285b89c8f943c127d7f06aa25d92c399632
extdiff: move from dict() construction to {} literals

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

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -207,10 +207,10 @@
         # Function to quote file/dir names in the argument string.
         # When not operating in 3-way mode, an empty string is
         # returned for parent2
-        replace = dict(parent=dir1a, parent1=dir1a, parent2=dir1b,
-                       plabel1=label1a, plabel2=label1b,
-                       clabel=label2, child=dir2,
-                       root=repo.root)
+        replace = {'parent': dir1a, 'parent1': dir1a, 'parent2': dir1b,
+                   'plabel1': label1a, 'plabel2': label1b,
+                   'clabel': label2, 'child': dir2,
+                   'root': repo.root}
         def quote(match):
             key = match.group()[1:]
             if not do3way and key == 'parent2':
@@ -316,7 +316,7 @@
     that revision is compared to the working directory, and, when no
     revisions are specified, the working directory files are compared
     to its parent.\
-''') % dict(path=util.uirepr(path))
+''') % {'path': util.uirepr(path)}
 
             # We must translate the docstring right away since it is
             # used as a format string. The string will unfortunately


More information about the Mercurial-devel mailing list