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

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


# HG changeset patch
# User Augie Fackler <raf at 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.

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)


More information about the Mercurial-devel mailing list