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

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2014, 5:40 p.m.
Message ID <37cde285b89c8f943c12.1394646037@augie-macbookair>
Download mbox | patch
Permalink /patch/3916/
State Accepted
Commit 37cde285b89c8f943c127d7f06aa25d92c399632
Headers show

Comments

Augie Fackler - March 12, 2014, 5:40 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1394644390 14400
#      Wed Mar 12 13:13:10 2014 -0400
# Node ID 37cde285b89c8f943c127d7f06aa25d92c399632
# Parent  05e58b08fdfe2bcda3708ab6c20fbcb5fc01b3cd
bugzilla: move from dict() construction to {} literals

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

Patch

diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -620,7 +620,7 @@ 
         ver = self.bzproxy.Bugzilla.version()['version'].split('.')
         self.bzvermajor = int(ver[0])
         self.bzverminor = int(ver[1])
-        self.bzproxy.User.login(dict(login=user, password=passwd))
+        self.bzproxy.User.login({'login': user, 'password': passwd})
 
     def transport(self, uri):
         if urlparse.urlparse(uri, "http")[0] == "https":
@@ -630,13 +630,15 @@ 
 
     def get_bug_comments(self, id):
         """Return a string with all comment text for a bug."""
-        c = self.bzproxy.Bug.comments(dict(ids=[id], include_fields=['text']))
+        c = self.bzproxy.Bug.comments({'ids': [id],
+                                       'include_fields': ['text']})
         return ''.join([t['text'] for t in c['bugs'][str(id)]['comments']])
 
     def filter_real_bug_ids(self, bugs):
-        probe = self.bzproxy.Bug.get(dict(ids=sorted(bugs.keys()),
-                                          include_fields=[],
-                                          permissive=True))
+        probe = self.bzproxy.Bug.get({'ids': sorted(bugs.keys()),
+                                      'include_fields': [],
+                                      'permissive': True,
+                                      })
         for badbug in probe['faults']:
             id = badbug['id']
             self.ui.status(_('bug %d does not exist\n') % id)
@@ -717,10 +719,10 @@ 
         than the subject line, and leave a blank line after it.
         '''
         user = self.map_committer(committer)
-        matches = self.bzproxy.User.get(dict(match=[user]))
+        matches = self.bzproxy.User.get({'match': [user]})
         if not matches['users']:
             user = self.ui.config('bugzilla', 'user', 'bugs')
-            matches = self.bzproxy.User.get(dict(match=[user]))
+            matches = self.bzproxy.User.get({'match': [user]})
             if not matches['users']:
                 raise util.Abort(_("default bugzilla user %s email not found") %
                                  user)