[PATCH] bugzilla: support sendbugmail.pl

Benoit Boissinot bboissin at gmail.com
Wed Oct 29 16:56:17 UTC 2008


On Wed, Oct 29, 2008 at 03:55:20PM +0000, Jim Hague wrote:
> # HG changeset patch
> # User Jim Hague <jim.hague at acm.org>
> # Date 1225294377 0
> # Node ID 0637381ee11c1701f63c49ff2c256d9e071d48a7
> # Parent  76634cb7fe7bc5c89fad8d15a878df1b239655be
> Bugzilla 2.18 and later use sendbugmail.pl, which requires committer name.
> 
> During 2.17, Bugzilla ditched the old 'processmail' script. With 2.18
> contrib/sendbugmail.pl arrived in its place.
> 
> For notification emails to work properly, sendbugmail.pl requires as
> its second parameter the Bugzilla user who made the commit. Otherwise
> the user will not be recognised as the committer, and will receive
> notification emails about the commit regardless of their preference
> about being notified on their own commits.
> 
> diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
> --- a/hgext/bugzilla.py
> +++ b/hgext/bugzilla.py
>  
> -class bugzilla_3_0(bugzilla_2_16):
> +class bugzilla_2_18(bugzilla_2_16):
> +    '''support for bugzilla 2.18 series. contrib/sendbugmail.pl
> +    replaces processmail and requires username of committer.'''
> +
> +    def __init__(self, ui):
> +        bugzilla_2_16.__init__(self, ui)
> +
> +    def notify(self, ids, ctx):
> +        '''tell bugzilla to send mail. Supply email of committer of change
> +        if they are a registered user, otherwise use default bugzilla user.'''
> +
> +        self.ui.status(_('telling bugzilla to send mail:\n'))
> +        (user, userid) = self.get_bugzilla_user(util.email(ctx.user()))
> +        for id in ids:
> +            self.ui.status(_('  bug %s\n') % id)
> +            cmd = self.ui.config('bugzilla', 'notify',
> +                               'cd /var/www/html/bugzilla && '
> +                               'contrib/sendbugmail.pl %s %s') % (id, user)
> +            fp = util.popen('(%s) 2>&1' % cmd)
> +            out = fp.read()
> +            ret = fp.close()
> +            if ret:
> +                self.ui.warn(out)
> +                raise util.Abort(_('bugzilla notify command %s') %
> +                                 util.explain_exit(ret)[0])

factor that with the other notify(), you could use:

self.default_notify = "cd /var/www/html/bugzilla && contrib/sendbugmail.pl %(id)s %(user)s"

and then:
cmd = self.ui.config('bugzilla', 'notify', self.default_notify % {'id': id, 'user': user})

then rest is common with the two version.

You should probably call util.shellquote() for user and id.

regards,

Benoit
-- 
:wq



More information about the Mercurial-devel mailing list