summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2012-10-19 01:16:29 -0400
committerStef Walter <stefw@gnome.org>2013-02-07 15:22:25 +0100
commit14be2b5978fdb20e9de908934d9db82a2f376c96 (patch)
treeb1b8ab9687ded76f352a81541c54f56d4bc65882
parent8d92019665ee13288f6483725c8cedd318812566 (diff)
WIP around freedesktop.org problemsfixes
-rwxr-xr-xgit-bz32
1 files changed, 31 insertions, 1 deletions
diff --git a/git-bz b/git-bz
index 3e9268d..36b53e0 100755
--- a/git-bz
+++ b/git-bz
@@ -1273,7 +1273,30 @@ class Bug(object):
print "Bug %d - %s" % (self.id, short_desc)
print self.get_url()
- def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'):
+ def _patch_via_xmlrpc(self, description, comment, filename, data, obsoletes, status):
+ params = dict()
+ params['ids'] = [str(self.id)]
+ params['data'] = data
+ params['file_name'] = filename
+ params['summary'] = description
+ params['content_type'] = 'text/plain; charset=UTF-8'
+ params['is_patch'] = '1'
+
+ try:
+ response = self.server.get_xmlrpc_proxy().Bug.add_attachment(params)
+ except xmlrpclib.Fault, e:
+ if "Failed to locate method" in e.faultString:
+ raise NoXmlRpcError("No add_attachment method")
+ die(e.faultString)
+ except xmlrpclib.ProtocolError, e:
+ if e.errcode == 404:
+ raise NoXmlRpcError(e.errmsg)
+ else:
+ print >>sys.stderr, "Problem creating attachment via XML-RPC: %s (%d)\n" % (e.errmsg, e.errcode)
+ print >>sys.stderr, "falling back to form post\n"
+ raise NoXmlRpcError("Communication error")
+
+ def _patch_via_form(self, description, comment, filename, data, obsoletes, status):
fields = {}
fields['bugid'] = str(self.id)
fields['action'] = 'insert'
@@ -1299,6 +1322,13 @@ class Bug(object):
print response_data
die ("Failed to attach patch to bug %d, status=%d" % (self.id, response.status))
+
+ def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'):
+ try:
+ self._patch_via_xmlrpc(description, comment, filename, data, obsoletes, status)
+ except NoXmlRpcError:
+ self._patch_via_form(description, comment, filename, data, obsoletes, status)
+
print "Attached %s" % filename
# Update specified fields of a bug; keyword arguments are interpreted