diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-02-10 09:36:23 +0000 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2015-02-12 15:09:34 -0500 |
commit | 2874294517f5867a2948db08e7ab03db073fb8c2 (patch) | |
tree | 063ac460fe4ed9e8daa327b0751fd55069cfbf7d | |
parent | 5ae7a500636ddc28bcf7a18427f388c8790623b3 (diff) | |
download | git-bz-2874294517f5867a2948db08e7ab03db073fb8c2.tar.gz |
Add support for attaching patches on Bugzilla 4.2+
attachment.cgi requires a token field for Bugzilla 4.2 and later.
(See https://bugzilla.mozilla.org/show_bug.cgi?id=703983)
This token is not the same as the overall bug's token. So from
we need to load attachment.cgi as a GET before every POST, which
is a bit of a pain.
https://bugzilla.gnome.org/show_bug.cgi?id=700502
-rwxr-xr-x | git-bz | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1245,9 +1245,25 @@ class Bug(object): print self.get_url() def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'): + # Bugzilla 4.2+ requires you to grab a fresh token from attachment.cgi. + url = "/attachment.cgi?bugid=" + str(self.id) + "&action=enter" + + try: + response = self.server.send_request("GET", url) + except KeyboardInterrupt: + die("Failed to retrieve attachment form: user cancelled") + if response.status != 200: + die("Failed to retrieve attachment form: %d" % response.status) + + token = re.search(r'<input type="hidden" name="token" value="(.+)">', + response.read()) + + # Build the new form. fields = {} fields['bugid'] = str(self.id) fields['action'] = 'insert' + if token is not None: + fields['token'] = token.group(1) fields['ispatch'] = '1' fields['attachments.status'] = status fields['description'] = description |