reviewboard: handle kwargs more robustly (bug 1235213); r?dminor draft
authorGregory Szorc <gps@mozilla.com>
Mon, 25 Jan 2016 23:11:40 -0800
changeset 6954 732487029bf70a8a69b9a0a9bd7b14dcc44719d0
parent 6953 be9a7fa2f79ae6b4eb0f4ba8ba17a9a15106249c
push id556
push usergszorc@mozilla.com
push dateTue, 26 Jan 2016 07:12:27 +0000
reviewersdminor
bugs1235213
reviewboard: handle kwargs more robustly (bug 1235213); r?dminor Mercurial 3.6 changed the "extra" keyword argument from an empty tuple to None. It's quite possible the mutability of that default argument was leading to our previous code not erroring. Setting the argument to an empty dict in all false-y cases makes the issue go away.
hgext/reviewboard/client.py
--- a/hgext/reviewboard/client.py
+++ b/hgext/reviewboard/client.py
@@ -1048,19 +1048,21 @@ def reposetup(ui, repo):
             """
             # Some callers of commit() may not pass named arguments. Slurp
             # extra from positional arguments.
             if len(args) == 7:
                 assert 'extra' not in kwargs
                 kwargs['extra'] = args[6]
                 args = tuple(args[0:6])
 
-            extra = kwargs.setdefault('extra', {})
-            if 'commitid' not in extra and self.reviews.remoteurl:
-                extra['commitid'] = genid(self)
+            if not kwargs['extra']:
+                kwargs['extra'] = {}
+
+            if 'commitid' not in kwargs['extra'] and self.reviews.remoteurl:
+                kwargs['extra']['commitid'] = genid(self)
 
             return super(reviewboardrepo, self).commit(*args, **kwargs)
 
     repo.__class__ = reviewboardrepo
     repo.noreviewboardpush = False
     repo.reviewid = None
 
     def prepushoutgoinghook(local, remote, outgoing):