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

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2014, 5:40 p.m.
Message ID <2aafd5854243fda62720.1394646038@augie-macbookair>
Download mbox | patch
Permalink /patch/3913/
State Accepted
Commit 2aafd5854243fda6272085846a435e3412e1b9d5
Headers show

Comments

Augie Fackler - March 12, 2014, 5:40 p.m.
# HG changeset patch
# User Augie Fackler <raf@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.

Patch

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