610 self.fixstatus = self.ui.config('bugzilla', 'fixstatus', 'RESOLVED') |
610 self.fixstatus = self.ui.config('bugzilla', 'fixstatus', 'RESOLVED') |
611 self.fixresolution = self.ui.config('bugzilla', 'fixresolution', |
611 self.fixresolution = self.ui.config('bugzilla', 'fixresolution', |
612 'FIXED') |
612 'FIXED') |
613 |
613 |
614 self.bzproxy = xmlrpclib.ServerProxy(bzweb, self.transport(bzweb)) |
614 self.bzproxy = xmlrpclib.ServerProxy(bzweb, self.transport(bzweb)) |
|
615 ver = self.bzproxy.Bugzilla.version()['version'].split('.') |
|
616 self.bzvermajor = int(ver[0]) |
|
617 self.bzverminor = int(ver[1]) |
615 self.bzproxy.User.login(dict(login=user, password=passwd)) |
618 self.bzproxy.User.login(dict(login=user, password=passwd)) |
616 |
619 |
617 def transport(self, uri): |
620 def transport(self, uri): |
618 if urlparse.urlparse(uri, "http")[0] == "https": |
621 if urlparse.urlparse(uri, "http")[0] == "https": |
619 return cookiesafetransport() |
622 return cookiesafetransport() |
671 There is no XMLRPC function to change bug status before Bugzilla |
674 There is no XMLRPC function to change bug status before Bugzilla |
672 4.0, so bugs cannot be marked fixed via XMLRPC before Bugzilla 4.0. |
675 4.0, so bugs cannot be marked fixed via XMLRPC before Bugzilla 4.0. |
673 But bugs can be marked fixed via email from 3.4 onwards. |
676 But bugs can be marked fixed via email from 3.4 onwards. |
674 """ |
677 """ |
675 |
678 |
|
679 # The email interface changes subtly between 3.4 and 3.6. In 3.4, |
|
680 # in-email fields are specified as '@<fieldname> = <value>'. In |
|
681 # 3.6 this becomes '@<fieldname> <value>'. And fieldname @bug_id |
|
682 # in 3.4 becomes @id in 3.6. 3.6 and 4.0 both maintain backwards |
|
683 # compatibility, but rather than rely on this use the new format for |
|
684 # 4.0 onwards. |
|
685 |
676 def __init__(self, ui): |
686 def __init__(self, ui): |
677 bzxmlrpc.__init__(self, ui) |
687 bzxmlrpc.__init__(self, ui) |
678 |
688 |
679 self.bzemail = self.ui.config('bugzilla', 'bzemail') |
689 self.bzemail = self.ui.config('bugzilla', 'bzemail') |
680 if not self.bzemail: |
690 if not self.bzemail: |
681 raise util.Abort(_("configuration 'bzemail' missing")) |
691 raise util.Abort(_("configuration 'bzemail' missing")) |
682 mail.validateconfig(self.ui) |
692 mail.validateconfig(self.ui) |
|
693 |
|
694 def makecommandline(self, fieldname, value): |
|
695 if self.bzvermajor >= 4: |
|
696 return "@%s %s" % (fieldname, str(value)) |
|
697 else: |
|
698 if fieldname == "id": |
|
699 fieldname = "bug_id" |
|
700 return "@%s = %s" % (fieldname, str(value)) |
683 |
701 |
684 def send_bug_modify_email(self, bugid, commands, comment, committer): |
702 def send_bug_modify_email(self, bugid, commands, comment, committer): |
685 '''send modification message to Bugzilla bug via email. |
703 '''send modification message to Bugzilla bug via email. |
686 |
704 |
687 The message format is documented in the Bugzilla email_in.pl |
705 The message format is documented in the Bugzilla email_in.pl |
699 matches = self.bzproxy.User.get(dict(match=[user])) |
717 matches = self.bzproxy.User.get(dict(match=[user])) |
700 if not matches['users']: |
718 if not matches['users']: |
701 raise util.Abort(_("default bugzilla user %s email not found") % |
719 raise util.Abort(_("default bugzilla user %s email not found") % |
702 user) |
720 user) |
703 user = matches['users'][0]['email'] |
721 user = matches['users'][0]['email'] |
704 |
722 commands.append(self.makecommandline("id", bugid)) |
705 text = "\n".join(commands) + "\n@bug_id = %d\n\n" % bugid + comment |
723 |
|
724 text = "\n".join(commands) + "\n\n" + comment |
706 |
725 |
707 _charsets = mail._charsets(self.ui) |
726 _charsets = mail._charsets(self.ui) |
708 user = mail.addressencode(self.ui, user, _charsets) |
727 user = mail.addressencode(self.ui, user, _charsets) |
709 bzemail = mail.addressencode(self.ui, self.bzemail, _charsets) |
728 bzemail = mail.addressencode(self.ui, self.bzemail, _charsets) |
710 msg = mail.mimeencode(self.ui, text, _charsets) |
729 msg = mail.mimeencode(self.ui, text, _charsets) |