hgext/bugzilla.py
changeset 9054 84be8a8cc8b0
parent 8935 f4f0e902b750
child 9203 e4dbd49b88a9
equal deleted inserted replaced
9053:6d0b5d76e76d 9054:84be8a8cc8b0
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2, incorporated herein by reference.
     6 # GNU General Public License version 2, incorporated herein by reference.
     7 
     7 
     8 '''hooks for integrating with the Bugzilla bug tracker
     8 '''hooks for integrating with the Bugzilla bug tracker
     9 
     9 
    10 This hook extension adds comments on bugs in Bugzilla when changesets
    10 This hook extension adds comments on bugs in Bugzilla when changesets that
    11 that refer to bugs by Bugzilla ID are seen. The hook does not change
    11 refer to bugs by Bugzilla ID are seen. The hook does not change bug status.
    12 bug status.
    12 
    13 
    13 The hook updates the Bugzilla database directly. Only Bugzilla installations
    14 The hook updates the Bugzilla database directly. Only Bugzilla
    14 using MySQL are supported.
    15 installations using MySQL are supported.
    15 
    16 
    16 The hook relies on a Bugzilla script to send bug change notification emails.
    17 The hook relies on a Bugzilla script to send bug change notification
    17 That script changes between Bugzilla versions; the 'processmail' script used
    18 emails. That script changes between Bugzilla versions; the
    18 prior to 2.18 is replaced in 2.18 and subsequent versions by
    19 'processmail' script used prior to 2.18 is replaced in 2.18 and
    19 'config/sendbugmail.pl'. Note that these will be run by Mercurial as the user
    20 subsequent versions by 'config/sendbugmail.pl'. Note that these will
    20 pushing the change; you will need to ensure the Bugzilla install file
    21 be run by Mercurial as the user pushing the change; you will need to
    21 permissions are set appropriately.
    22 ensure the Bugzilla install file permissions are set appropriately.
       
    23 
    22 
    24 Configuring the extension:
    23 Configuring the extension:
    25 
    24 
    26     [bugzilla]
    25     [bugzilla]
    27 
    26 
    28     host       Hostname of the MySQL server holding the Bugzilla
    27     host       Hostname of the MySQL server holding the Bugzilla database.
    29                database.
       
    30     db         Name of the Bugzilla database in MySQL. Default 'bugs'.
    28     db         Name of the Bugzilla database in MySQL. Default 'bugs'.
    31     user       Username to use to access MySQL server. Default 'bugs'.
    29     user       Username to use to access MySQL server. Default 'bugs'.
    32     password   Password to use to access MySQL server.
    30     password   Password to use to access MySQL server.
    33     timeout    Database connection timeout (seconds). Default 5.
    31     timeout    Database connection timeout (seconds). Default 5.
    34     version    Bugzilla version. Specify '3.0' for Bugzilla versions
    32     version    Bugzilla version. Specify '3.0' for Bugzilla versions 3.0 and
    35                3.0 and later, '2.18' for Bugzilla versions from 2.18
    33                later, '2.18' for Bugzilla versions from 2.18 and '2.16' for
    36                and '2.16' for versions prior to 2.18.
    34                versions prior to 2.18.
    37     bzuser     Fallback Bugzilla user name to record comments with, if
    35     bzuser     Fallback Bugzilla user name to record comments with, if
    38                changeset committer cannot be found as a Bugzilla user.
    36                changeset committer cannot be found as a Bugzilla user.
    39     bzdir      Bugzilla install directory. Used by default notify.
    37     bzdir      Bugzilla install directory. Used by default notify. Default
    40                Default '/var/www/html/bugzilla'.
    38                '/var/www/html/bugzilla'.
    41     notify     The command to run to get Bugzilla to send bug change
    39     notify     The command to run to get Bugzilla to send bug change
    42                notification emails. Substitutes from a map with 3
    40                notification emails. Substitutes from a map with 3 keys,
    43                keys, 'bzdir', 'id' (bug id) and 'user' (committer
    41                'bzdir', 'id' (bug id) and 'user' (committer bugzilla email).
    44                bugzilla email). Default depends on version; from 2.18
    42                Default depends on version; from 2.18 it is "cd %(bzdir)s &&
    45                it is "cd %(bzdir)s && perl -T contrib/sendbugmail.pl
    43                perl -T contrib/sendbugmail.pl %(id)s %(user)s".
    46                %(id)s %(user)s".
       
    47     regexp     Regular expression to match bug IDs in changeset commit
    44     regexp     Regular expression to match bug IDs in changeset commit
    48                message. Must contain one "()" group. The default
    45                message. Must contain one "()" group. The default expression
    49                expression matches 'Bug 1234', 'Bug no. 1234', 'Bug
    46                matches 'Bug 1234', 'Bug no. 1234', 'Bug number 1234', 'Bugs
    50                number 1234', 'Bugs 1234,5678', 'Bug 1234 and 5678' and
    47                1234,5678', 'Bug 1234 and 5678' and variations thereof.
    51                variations thereof. Matching is case insensitive.
    48                Matching is case insensitive.
    52     style      The style file to use when formatting comments.
    49     style      The style file to use when formatting comments.
    53     template   Template to use when formatting comments. Overrides
    50     template   Template to use when formatting comments. Overrides style if
    54                style if specified. In addition to the usual Mercurial
    51                specified. In addition to the usual Mercurial keywords, the
    55                keywords, the extension specifies:
    52                extension specifies:
    56                    {bug}       The Bugzilla bug ID.
    53                    {bug}       The Bugzilla bug ID.
    57                    {root}      The full pathname of the Mercurial
    54                    {root}      The full pathname of the Mercurial repository.
    58                                repository.
    55                    {webroot}   Stripped pathname of the Mercurial repository.
    59                    {webroot}   Stripped pathname of the Mercurial
    56                    {hgweb}     Base URL for browsing Mercurial repositories.
    60                                repository.
       
    61                    {hgweb}     Base URL for browsing Mercurial
       
    62                                repositories.
       
    63                Default 'changeset {node|short} in repo {root} refers '
    57                Default 'changeset {node|short} in repo {root} refers '
    64                        'to bug {bug}.\\ndetails:\\n\\t{desc|tabindent}'
    58                        'to bug {bug}.\\ndetails:\\n\\t{desc|tabindent}'
    65     strip      The number of slashes to strip from the front of {root}
    59     strip      The number of slashes to strip from the front of {root} to
    66                to produce {webroot}. Default 0.
    60                produce {webroot}. Default 0.
    67     usermap    Path of file containing Mercurial committer ID to
    61     usermap    Path of file containing Mercurial committer ID to Bugzilla user
    68                Bugzilla user ID mappings. If specified, the file
    62                ID mappings. If specified, the file should contain one mapping
    69                should contain one mapping per line,
    63                per line, "committer"="Bugzilla user". See also the [usermap]
    70                "committer"="Bugzilla user". See also the [usermap]
       
    71                section.
    64                section.
    72 
    65 
    73     [usermap]
    66     [usermap]
    74     Any entries in this section specify mappings of Mercurial
    67     Any entries in this section specify mappings of Mercurial committer ID to
    75     committer ID to Bugzilla user ID. See also [bugzilla].usermap.
    68     Bugzilla user ID. See also [bugzilla].usermap. "committer"="Bugzilla user"
    76     "committer"="Bugzilla user"
       
    77 
    69 
    78     [web]
    70     [web]
    79     baseurl    Base URL for browsing Mercurial repositories. Reference
    71     baseurl    Base URL for browsing Mercurial repositories. Reference from
    80                from templates as {hgweb}.
    72                templates as {hgweb}.
    81 
    73 
    82 Activating the extension:
    74 Activating the extension:
    83 
    75 
    84     [extensions]
    76     [extensions]
    85     hgext.bugzilla =
    77     hgext.bugzilla =
    88     # run bugzilla hook on every change pulled or pushed in here
    80     # run bugzilla hook on every change pulled or pushed in here
    89     incoming.bugzilla = python:hgext.bugzilla.hook
    81     incoming.bugzilla = python:hgext.bugzilla.hook
    90 
    82 
    91 Example configuration:
    83 Example configuration:
    92 
    84 
    93 This example configuration is for a collection of Mercurial
    85 This example configuration is for a collection of Mercurial repositories in
    94 repositories in /var/local/hg/repos/ used with a local Bugzilla 3.2
    86 /var/local/hg/repos/ used with a local Bugzilla 3.2 installation in
    95 installation in /opt/bugzilla-3.2.
    87 /opt/bugzilla-3.2.
    96 
    88 
    97     [bugzilla]
    89     [bugzilla]
    98     host=localhost
    90     host=localhost
    99     password=XYZZY
    91     password=XYZZY
   100     version=3.0
    92     version=3.0