author | Martin von Zweigbergk <martinvonz@google.com> |
Tue, 10 Dec 2019 14:40:44 -0800 | |
changeset 43838 | a47ccdcce4f9 |
parent 43506 | 9f70512ae2cf |
child 43970 | 3194cc8c8de0 |
permissions | -rw-r--r-- |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1 |
# bugzilla.py - bugzilla integration for mercurial |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
2 |
# |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
4 |
# Copyright 2011-4 Jim Hague <jim.hague@acm.org> |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
5 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
10263 | 7 |
# GNU General Public License version 2 or any later version. |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
8 |
|
8935
f4f0e902b750
extensions: change descriptions for hook-providing extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8894
diff
changeset
|
9 |
'''hooks for integrating with the Bugzilla bug tracker |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
10 |
|
9252
b03aa86f4c10
bugzilla: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9204
diff
changeset
|
11 |
This hook extension adds comments on bugs in Bugzilla when changesets |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
12 |
that refer to bugs by Bugzilla ID are seen. The comment is formatted using |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
13 |
the Mercurial template mechanism. |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
14 |
|
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
15 |
The bug references can optionally include an update for Bugzilla of the |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
16 |
hours spent working on the bug. Bugs can also be marked fixed. |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
17 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
18 |
Four basic modes of access to Bugzilla are provided: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
19 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
20 |
1. Access via the Bugzilla REST-API. Requires bugzilla 5.0 or later. |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
21 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
22 |
2. Access via the Bugzilla XMLRPC interface. Requires Bugzilla 3.4 or later. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
23 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
24 |
3. Check data via the Bugzilla XMLRPC interface and submit bug change |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
25 |
via email to Bugzilla email interface. Requires Bugzilla 3.4 or later. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
26 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
27 |
4. Writing directly to the Bugzilla database. Only Bugzilla installations |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
28 |
using MySQL are supported. Requires Python MySQLdb. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
29 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
30 |
Writing directly to the database is susceptible to schema changes, and |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
31 |
relies on a Bugzilla contrib script to send out bug change |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
32 |
notification emails. This script runs as the user running Mercurial, |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
33 |
must be run on the host with the Bugzilla install, and requires |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
34 |
permission to read Bugzilla configuration details and the necessary |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
35 |
MySQL user and password to have full access rights to the Bugzilla |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
36 |
database. For these reasons this access mode is now considered |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
37 |
deprecated, and will not be updated for new Bugzilla versions going |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
38 |
forward. Only adding comments is supported in this access mode. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
39 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
40 |
Access via XMLRPC needs a Bugzilla username and password to be specified |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
41 |
in the configuration. Comments are added under that username. Since the |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
42 |
configuration must be readable by all Mercurial users, it is recommended |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
43 |
that the rights of that user are restricted in Bugzilla to the minimum |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
44 |
necessary to add comments. Marking bugs fixed requires Bugzilla 4.0 and later. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
45 |
|
13871
22d200e49b10
bugzilla: more documentation fixes
Jim Hague <jim.hague@acm.org>
parents:
13870
diff
changeset
|
46 |
Access via XMLRPC/email uses XMLRPC to query Bugzilla, but sends |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
47 |
email to the Bugzilla email interface to submit comments to bugs. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
48 |
The From: address in the email is set to the email address of the Mercurial |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
49 |
user, so the comment appears to come from the Mercurial user. In the event |
17534 | 50 |
that the Mercurial user email is not recognized by Bugzilla as a Bugzilla |
13871
22d200e49b10
bugzilla: more documentation fixes
Jim Hague <jim.hague@acm.org>
parents:
13870
diff
changeset
|
51 |
user, the email associated with the Bugzilla username used to log into |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
52 |
Bugzilla is used instead as the source of the comment. Marking bugs fixed |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
53 |
works on all supported Bugzilla versions. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
54 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
55 |
Access via the REST-API needs either a Bugzilla username and password |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
56 |
or an apikey specified in the configuration. Comments are made under |
32574
870248603a4e
bugzilla: fix typo in help text
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
31570
diff
changeset
|
57 |
the given username or the user associated with the apikey in Bugzilla. |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
58 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
59 |
Configuration items common to all access modes: |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
60 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
61 |
bugzilla.version |
17537 | 62 |
The access type to use. Values recognized are: |
13871
22d200e49b10
bugzilla: more documentation fixes
Jim Hague <jim.hague@acm.org>
parents:
13870
diff
changeset
|
63 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
64 |
:``restapi``: Bugzilla REST-API, Bugzilla 5.0 and later. |
13883
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
65 |
:``xmlrpc``: Bugzilla XMLRPC interface. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
66 |
:``xmlrpc+email``: Bugzilla XMLRPC and email interfaces. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
67 |
:``3.0``: MySQL access, Bugzilla 3.0 and later. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
68 |
:``2.18``: MySQL access, Bugzilla 2.18 and up to but not |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
69 |
including 3.0. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
70 |
:``2.16``: MySQL access, Bugzilla 2.16 and up to but not |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
71 |
including 2.18. |
7985
0edca606c0f1
bugzilla: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7762
diff
changeset
|
72 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
73 |
bugzilla.regexp |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
74 |
Regular expression to match bug IDs for update in changeset commit message. |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
75 |
It must contain one "()" named group ``<ids>`` containing the bug |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
76 |
IDs separated by non-digit characters. It may also contain |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
77 |
a named group ``<hours>`` with a floating-point number giving the |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
78 |
hours worked on the bug. If no named groups are present, the first |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
79 |
"()" group is assumed to contain the bug IDs, and work time is not |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
80 |
updated. The default expression matches ``Bug 1234``, ``Bug no. 1234``, |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
81 |
``Bug number 1234``, ``Bugs 1234,5678``, ``Bug 1234 and 5678`` and |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
82 |
variations thereof, followed by an hours number prefixed by ``h`` or |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
83 |
``hours``, e.g. ``hours 1.5``. Matching is case insensitive. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
84 |
|
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
85 |
bugzilla.fixregexp |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
86 |
Regular expression to match bug IDs for marking fixed in changeset |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
87 |
commit message. This must contain a "()" named group ``<ids>` containing |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
88 |
the bug IDs separated by non-digit characters. It may also contain |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
89 |
a named group ``<hours>`` with a floating-point number giving the |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
90 |
hours worked on the bug. If no named groups are present, the first |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
91 |
"()" group is assumed to contain the bug IDs, and work time is not |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
92 |
updated. The default expression matches ``Fixes 1234``, ``Fixes bug 1234``, |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
93 |
``Fixes bugs 1234,5678``, ``Fixes 1234 and 5678`` and |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
94 |
variations thereof, followed by an hours number prefixed by ``h`` or |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
95 |
``hours``, e.g. ``hours 1.5``. Matching is case insensitive. |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
96 |
|
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
97 |
bugzilla.fixstatus |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
98 |
The status to set a bug to when marking fixed. Default ``RESOLVED``. |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
99 |
|
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
100 |
bugzilla.fixresolution |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
101 |
The resolution to set a bug to when marking fixed. Default ``FIXED``. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
102 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
103 |
bugzilla.style |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
104 |
The style file to use when formatting comments. |
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
105 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
106 |
bugzilla.template |
9252
b03aa86f4c10
bugzilla: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9204
diff
changeset
|
107 |
Template to use when formatting comments. Overrides style if |
b03aa86f4c10
bugzilla: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9204
diff
changeset
|
108 |
specified. In addition to the usual Mercurial keywords, the |
13884
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
109 |
extension specifies: |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
110 |
|
13884
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
111 |
:``{bug}``: The Bugzilla bug ID. |
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
112 |
:``{root}``: The full pathname of the Mercurial repository. |
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
113 |
:``{webroot}``: Stripped pathname of the Mercurial repository. |
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
114 |
:``{hgweb}``: Base URL for browsing Mercurial repositories. |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
115 |
|
13842
4cffce61bd92
bugzilla: fix bad reST markup
Martin Geisler <mg@aragost.com>
parents:
13841
diff
changeset
|
116 |
Default ``changeset {node|short} in repo {root} refers to bug |
4cffce61bd92
bugzilla: fix bad reST markup
Martin Geisler <mg@aragost.com>
parents:
13841
diff
changeset
|
117 |
{bug}.\\ndetails:\\n\\t{desc|tabindent}`` |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
118 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
119 |
bugzilla.strip |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
120 |
The number of path separator characters to strip from the front of |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
121 |
the Mercurial repository path (``{root}`` in templates) to produce |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
122 |
``{webroot}``. For example, a repository with ``{root}`` |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
123 |
``/var/local/my-project`` with a strip of 2 gives a value for |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
124 |
``{webroot}`` of ``my-project``. Default 0. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
125 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
126 |
web.baseurl |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
127 |
Base URL for browsing Mercurial repositories. Referenced from |
13896
3b4025dcb223
bugzilla: more documentation formatting fixups
Jim Hague <jim.hague@acm.org>
parents:
13884
diff
changeset
|
128 |
templates as ``{hgweb}``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
129 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
130 |
Configuration items common to XMLRPC+email and MySQL access modes: |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
131 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
132 |
bugzilla.usermap |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
133 |
Path of file containing Mercurial committer email to Bugzilla user email |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
134 |
mappings. If specified, the file should contain one mapping per |
13835
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
135 |
line:: |
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
136 |
|
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
137 |
committer = Bugzilla user |
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
138 |
|
13896
3b4025dcb223
bugzilla: more documentation formatting fixups
Jim Hague <jim.hague@acm.org>
parents:
13884
diff
changeset
|
139 |
See also the ``[usermap]`` section. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
140 |
|
13836
ed15922af2f9
bugzilla: markup section names as literal text
Martin Geisler <mg@aragost.com>
parents:
13835
diff
changeset
|
141 |
The ``[usermap]`` section is used to specify mappings of Mercurial |
13834
0aa2cfd0b21a
bugzilla: use standard section.name notation
Martin Geisler <mg@aragost.com>
parents:
13833
diff
changeset
|
142 |
committer email to Bugzilla user email. See also ``bugzilla.usermap``. |
13835
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
143 |
Contains entries of the form ``committer = Bugzilla user``. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
144 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
145 |
XMLRPC and REST-API access mode configuration: |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
146 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
147 |
bugzilla.bzurl |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
148 |
The base URL for the Bugzilla installation. |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
149 |
Default ``http://localhost/bugzilla``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
150 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
151 |
bugzilla.user |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
152 |
The username to use to log into Bugzilla via XMLRPC. Default |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
153 |
``bugs``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
154 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
155 |
bugzilla.password |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
156 |
The password for Bugzilla login. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
157 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
158 |
REST-API access mode uses the options listed above as well as: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
159 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
160 |
bugzilla.apikey |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
161 |
An apikey generated on the Bugzilla instance for api access. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
162 |
Using an apikey removes the need to store the user and password |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
163 |
options. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
164 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
165 |
XMLRPC+email access mode uses the XMLRPC access mode configuration items, |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
166 |
and also: |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
167 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
168 |
bugzilla.bzemail |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
169 |
The Bugzilla email address. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
170 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
171 |
In addition, the Mercurial email settings must be configured. See the |
13837
22f20d0fe2d3
bugzilla: refer to hgrc(5) man page with normal notation
Martin Geisler <mg@aragost.com>
parents:
13836
diff
changeset
|
172 |
documentation in hgrc(5), sections ``[email]`` and ``[smtp]``. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
173 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
174 |
MySQL access mode configuration: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
175 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
176 |
bugzilla.host |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
177 |
Hostname of the MySQL server holding the Bugzilla database. |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
178 |
Default ``localhost``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
179 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
180 |
bugzilla.db |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
181 |
Name of the Bugzilla database in MySQL. Default ``bugs``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
182 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
183 |
bugzilla.user |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
184 |
Username to use to access MySQL server. Default ``bugs``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
185 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
186 |
bugzilla.password |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
187 |
Password to use to access MySQL server. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
188 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
189 |
bugzilla.timeout |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
190 |
Database connection timeout (seconds). Default 5. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
191 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
192 |
bugzilla.bzuser |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
193 |
Fallback Bugzilla user name to record comments with, if changeset |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
194 |
committer cannot be found as a Bugzilla user. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
195 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
196 |
bugzilla.bzdir |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
197 |
Bugzilla install directory. Used by default notify. Default |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
198 |
``/var/www/html/bugzilla``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
199 |
|
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
200 |
bugzilla.notify |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
201 |
The command to run to get Bugzilla to send bug change notification |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
202 |
emails. Substitutes from a map with 3 keys, ``bzdir``, ``id`` (bug |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
203 |
id) and ``user`` (committer bugzilla email). Default depends on |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
204 |
version; from 2.18 it is "cd %(bzdir)s && perl -T |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
205 |
contrib/sendbugmail.pl %(id)s %(user)s". |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
206 |
|
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
207 |
Activating the extension:: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
208 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
209 |
[extensions] |
10112
703db37d186b
hgext: enable extensions without "hgext." prefix in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9252
diff
changeset
|
210 |
bugzilla = |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
211 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
212 |
[hooks] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
213 |
# run bugzilla hook on every change pulled or pushed in here |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
214 |
incoming.bugzilla = python:hgext.bugzilla.hook |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
215 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
216 |
Example configurations: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
217 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
218 |
XMLRPC example configuration. This uses the Bugzilla at |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
219 |
``http://my-project.org/bugzilla``, logging in as user |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
220 |
``bugmail@my-project.org`` with password ``plugh``. It is used with a |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
221 |
collection of Mercurial repositories in ``/var/local/hg/repos/``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
222 |
with a web interface at ``http://my-project.org/hg``. :: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
223 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
224 |
[bugzilla] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
225 |
bzurl=http://my-project.org/bugzilla |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
226 |
user=bugmail@my-project.org |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
227 |
password=plugh |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
228 |
version=xmlrpc |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
229 |
template=Changeset {node|short} in {root|basename}. |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
230 |
{hgweb}/{webroot}/rev/{node|short}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
231 |
{desc}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
232 |
strip=5 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
233 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
234 |
[web] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
235 |
baseurl=http://my-project.org/hg |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
236 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
237 |
XMLRPC+email example configuration. This uses the Bugzilla at |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
238 |
``http://my-project.org/bugzilla``, logging in as user |
14619
29f55c0e39e7
bugzilla: fix typo in documentation
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14234
diff
changeset
|
239 |
``bugmail@my-project.org`` with password ``plugh``. It is used with a |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
240 |
collection of Mercurial repositories in ``/var/local/hg/repos/``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
241 |
with a web interface at ``http://my-project.org/hg``. Bug comments |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
242 |
are sent to the Bugzilla email address |
13854
5ed036e42fd9
bugzilla: fix documentation typo
Patrick Mezard <pmezard@gmail.com>
parents:
13842
diff
changeset
|
243 |
``bugzilla@my-project.org``. :: |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
244 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
245 |
[bugzilla] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
246 |
bzurl=http://my-project.org/bugzilla |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
247 |
user=bugmail@my-project.org |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
248 |
password=plugh |
21842
fd2527d9b995
bugzilla: correct config documentation error
Jim Hague <jim.hague@acm.org>
parents:
21542
diff
changeset
|
249 |
version=xmlrpc+email |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
250 |
bzemail=bugzilla@my-project.org |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
251 |
template=Changeset {node|short} in {root|basename}. |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
252 |
{hgweb}/{webroot}/rev/{node|short}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
253 |
{desc}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
254 |
strip=5 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
255 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
256 |
[web] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
257 |
baseurl=http://my-project.org/hg |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
258 |
|
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
259 |
[usermap] |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
260 |
user@emaildomain.com=user.name@bugzilladomain.com |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
261 |
|
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
262 |
MySQL example configuration. This has a local Bugzilla 3.2 installation |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
263 |
in ``/opt/bugzilla-3.2``. The MySQL database is on ``localhost``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
264 |
the Bugzilla database name is ``bugs`` and MySQL is |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
265 |
accessed with MySQL username ``bugs`` password ``XYZZY``. It is used |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
266 |
with a collection of Mercurial repositories in ``/var/local/hg/repos/``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
267 |
with a web interface at ``http://my-project.org/hg``. :: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
268 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
269 |
[bugzilla] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
270 |
host=localhost |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
271 |
password=XYZZY |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
272 |
version=3.0 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
273 |
bzuser=unknown@domain.com |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
274 |
bzdir=/opt/bugzilla-3.2 |
9204
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
275 |
template=Changeset {node|short} in {root|basename}. |
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
276 |
{hgweb}/{webroot}/rev/{node|short}\\n |
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
277 |
{desc}\\n |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
278 |
strip=5 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
279 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
280 |
[web] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
281 |
baseurl=http://my-project.org/hg |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
282 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
283 |
[usermap] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
284 |
user@emaildomain.com=user.name@bugzilladomain.com |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
285 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
286 |
All the above add a comment to the Bugzilla bug record of the form:: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
287 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
288 |
Changeset 3b16791d6642 in repository-name. |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
289 |
http://my-project.org/hg/repository-name/rev/3b16791d6642 |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
290 |
|
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
291 |
Changeset commit comment. Bug 1234. |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
292 |
''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
293 |
|
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
294 |
from __future__ import absolute_import |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
295 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
296 |
import json |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
297 |
import re |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
298 |
import time |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
299 |
|
3891 | 300 |
from mercurial.i18n import _ |
6211
f89fd07fc51d
Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents:
5975
diff
changeset
|
301 |
from mercurial.node import short |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
302 |
from mercurial import ( |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
303 |
error, |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35151
diff
changeset
|
304 |
logcmdutil, |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
305 |
mail, |
41343
7370f302be71
py3: port test-bugzilla.t to Python 3
Augie Fackler <augie@google.com>
parents:
37463
diff
changeset
|
306 |
pycompat, |
33393
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
307 |
registrar, |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
308 |
url, |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
309 |
util, |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
310 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35954
diff
changeset
|
311 |
from mercurial.utils import ( |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
312 |
procutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35954
diff
changeset
|
313 |
stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35954
diff
changeset
|
314 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
315 |
|
29432
34b914ac573e
py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29431
diff
changeset
|
316 |
xmlrpclib = util.xmlrpclib |
29431
80880ad3fccd
py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28950
diff
changeset
|
317 |
|
29841
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29432
diff
changeset
|
318 |
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24987
diff
changeset
|
319 |
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24987
diff
changeset
|
320 |
# be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24987
diff
changeset
|
321 |
# leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
322 |
testedwith = b'ships-with-hg-core' |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16683
diff
changeset
|
323 |
|
33393
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
324 |
configtable = {} |
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
325 |
configitem = registrar.configitem(configtable) |
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
326 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
327 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
328 |
b'bugzilla', b'apikey', default=b'', |
33393
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
329 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
330 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
331 |
b'bugzilla', b'bzdir', default=b'/var/www/html/bugzilla', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
332 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
333 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
334 |
b'bugzilla', b'bzemail', default=None, |
33394
a752d2e7ec9c
configitems: register the 'bugzilla.bzdir' config
Boris Feld <boris.feld@octobus.net>
parents:
33393
diff
changeset
|
335 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
336 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
337 |
b'bugzilla', b'bzurl', default=b'http://localhost/bugzilla/', |
33395
b33d63651693
configitems: register the 'bugzilla.bzemail' config
Boris Feld <boris.feld@octobus.net>
parents:
33394
diff
changeset
|
338 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
339 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
340 |
b'bugzilla', b'bzuser', default=None, |
33396
96d3e5c1fd25
configitems: register the 'bugzilla.bzurl' config
Boris Feld <boris.feld@octobus.net>
parents:
33395
diff
changeset
|
341 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
342 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
343 |
b'bugzilla', b'db', default=b'bugs', |
33397
f656a4184a99
configitems: register the 'bugzilla.bzuser' config
Boris Feld <boris.feld@octobus.net>
parents:
33396
diff
changeset
|
344 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
345 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
346 |
b'bugzilla', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 |
b'fixregexp', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
348 |
default=( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
349 |
br'fix(?:es)?\s*(?:bugs?\s*)?,?\s*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
350 |
br'(?:nos?\.?|num(?:ber)?s?)?\s*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
351 |
br'(?P<ids>(?:#?\d+\s*(?:,?\s*(?:and)?)?\s*)+)' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
352 |
br'\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
353 |
), |
33399
bab1f3242140
configitems: register the 'bugzilla.fixregexp' config
Boris Feld <boris.feld@octobus.net>
parents:
33398
diff
changeset
|
354 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
355 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
356 |
b'bugzilla', b'fixresolution', default=b'FIXED', |
33400
76ca5097a2b6
configitems: register the 'bugzilla.fixresolution' config
Boris Feld <boris.feld@octobus.net>
parents:
33399
diff
changeset
|
357 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
358 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
359 |
b'bugzilla', b'fixstatus', default=b'RESOLVED', |
33401
960350659fa5
configitems: register the 'bugzilla.fixstatus' config
Boris Feld <boris.feld@octobus.net>
parents:
33400
diff
changeset
|
360 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
361 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
362 |
b'bugzilla', b'host', default=b'localhost', |
33402
26e4ba058215
configitems: register the 'bugzilla.host' config
Boris Feld <boris.feld@octobus.net>
parents:
33401
diff
changeset
|
363 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
364 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
365 |
b'bugzilla', b'notify', default=configitem.dynamicdefault, |
33524
a89f8329e0b0
configitems: register the 'bugzilla.notify' config
Boris Feld <boris.feld@octobus.net>
parents:
33470
diff
changeset
|
366 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
367 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
368 |
b'bugzilla', b'password', default=None, |
33433
f793e535b4b9
configitems: register the 'bugzilla.password' config
Boris Feld <boris.feld@octobus.net>
parents:
33402
diff
changeset
|
369 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
370 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
371 |
b'bugzilla', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
372 |
b'regexp', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
373 |
default=( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
374 |
br'bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
375 |
br'(?P<ids>(?:\d+\s*(?:,?\s*(?:and)?)?\s*)+)' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
376 |
br'\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
377 |
), |
33462
c841712253d5
configitems: register the 'bugzilla.regexp' config
Boris Feld <boris.feld@octobus.net>
parents:
33433
diff
changeset
|
378 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
379 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
380 |
b'bugzilla', b'strip', default=0, |
33463
037d809737fb
configitems: register the 'bugzilla.strip' config
Boris Feld <boris.feld@octobus.net>
parents:
33462
diff
changeset
|
381 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
382 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
383 |
b'bugzilla', b'style', default=None, |
33464
56f98a3f97d2
configitems: register the 'bugzilla.style' config
Boris Feld <boris.feld@octobus.net>
parents:
33463
diff
changeset
|
384 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
385 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
386 |
b'bugzilla', b'template', default=None, |
33465
9a36b964165e
configitems: register the 'bugzilla.template' config
Boris Feld <boris.feld@octobus.net>
parents:
33464
diff
changeset
|
387 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
388 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
389 |
b'bugzilla', b'timeout', default=5, |
33466
9443a946efdc
configitems: register the 'bugzilla.timeout' config
Boris Feld <boris.feld@octobus.net>
parents:
33465
diff
changeset
|
390 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
391 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 |
b'bugzilla', b'user', default=b'bugs', |
33467
6de2cd9d9258
configitems: register the 'bugzilla.user' config
Boris Feld <boris.feld@octobus.net>
parents:
33466
diff
changeset
|
393 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
394 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
395 |
b'bugzilla', b'usermap', default=None, |
33468
76269ea96935
configitems: register the 'bugzilla.usermap' config
Boris Feld <boris.feld@octobus.net>
parents:
33467
diff
changeset
|
396 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
397 |
configitem( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
398 |
b'bugzilla', b'version', default=None, |
33469
f2abf23a4d7b
configitems: register the 'bugzilla.version' config
Boris Feld <boris.feld@octobus.net>
parents:
33468
diff
changeset
|
399 |
) |
33393
01a90fed5840
configitems: register the 'bugzilla.apikey' config
Boris Feld <boris.feld@octobus.net>
parents:
32839
diff
changeset
|
400 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
401 |
|
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
402 |
class bzaccess(object): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
403 |
'''Base class for access to Bugzilla.''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
404 |
|
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
405 |
def __init__(self, ui): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
406 |
self.ui = ui |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
407 |
usermap = self.ui.config(b'bugzilla', b'usermap') |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
408 |
if usermap: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
409 |
self.ui.readconfig(usermap, sections=[b'usermap']) |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
410 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
411 |
def map_committer(self, user): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
412 |
'''map name of committer to Bugzilla user name.''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 |
for committer, bzuser in self.ui.configitems(b'usermap'): |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
414 |
if committer.lower() == user.lower(): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
415 |
return bzuser |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
416 |
return user |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
417 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
418 |
# Methods to be implemented by access classes. |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
419 |
# |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
420 |
# 'bugs' is a dict keyed on bug id, where values are a dict holding |
17534 | 421 |
# updates to bug state. Recognized dict keys are: |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
422 |
# |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
423 |
# 'hours': Value, float containing work hours to be updated. |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
424 |
# 'fix': If key present, bug is to be marked fixed. Value ignored. |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
425 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
426 |
def filter_real_bug_ids(self, bugs): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
427 |
'''remove bug IDs that do not exist in Bugzilla from bugs.''' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
428 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
429 |
def filter_cset_known_bug_ids(self, node, bugs): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
430 |
'''remove bug IDs where node occurs in comment text from bugs.''' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
431 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
432 |
def updatebug(self, bugid, newstate, text, committer): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
433 |
'''update the specified bug. Add comment text and set new states. |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
434 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
435 |
If possible add the comment as being from the committer of |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
436 |
the changeset. Otherwise use the default Bugzilla user. |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
437 |
''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
438 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
439 |
def notify(self, bugs, committer): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
440 |
'''Force sending of Bugzilla notification emails. |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
441 |
|
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
442 |
Only required if the access method does not trigger notification |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
443 |
emails automatically. |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
444 |
''' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
445 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
446 |
|
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
447 |
# Bugzilla via direct access to MySQL database. |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
448 |
class bzmysql(bzaccess): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
449 |
'''Support for direct MySQL access to Bugzilla. |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
450 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
451 |
The earliest Bugzilla version this is tested with is version 2.16. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
452 |
|
16226
674ecd23c42c
bugzilla: correct comment typo
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
453 |
If your Bugzilla is version 3.4 or above, you are strongly |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
454 |
recommended to use the XMLRPC access method instead. |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
455 |
''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
456 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
457 |
@staticmethod |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
458 |
def sql_buglist(ids): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
459 |
'''return SQL-friendly list of bug ids''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
460 |
return b'(' + b','.join(map(str, ids)) + b')' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
461 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
462 |
_MySQLdb = None |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
463 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
464 |
def __init__(self, ui): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
465 |
try: |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
466 |
import MySQLdb as mysql |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
467 |
|
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
468 |
bzmysql._MySQLdb = mysql |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25186
diff
changeset
|
469 |
except ImportError as err: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
470 |
raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
471 |
_(b'python mysql support not available: %s') % err |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 |
) |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
473 |
|
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
474 |
bzaccess.__init__(self, ui) |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
475 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
476 |
host = self.ui.config(b'bugzilla', b'host') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
477 |
user = self.ui.config(b'bugzilla', b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
478 |
passwd = self.ui.config(b'bugzilla', b'password') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
479 |
db = self.ui.config(b'bugzilla', b'db') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
480 |
timeout = int(self.ui.config(b'bugzilla', b'timeout')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
481 |
self.ui.note( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
482 |
_(b'connecting to %s:%s as %s, password %s\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 |
% (host, db, user, b'*' * len(passwd)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
484 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
485 |
self.conn = bzmysql._MySQLdb.connect( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
486 |
host=host, user=user, passwd=passwd, db=db, connect_timeout=timeout |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
487 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
488 |
self.cursor = self.conn.cursor() |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
489 |
self.longdesc_id = self.get_longdesc_id() |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
490 |
self.user_ids = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
491 |
self.default_notify = b"cd %(bzdir)s && ./processmail %(id)s %(user)s" |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
492 |
|
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
493 |
def run(self, *args, **kwargs): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
494 |
'''run a query.''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
495 |
self.ui.note(_(b'query: %s %s\n') % (args, kwargs)) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
496 |
try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
497 |
self.cursor.execute(*args, **kwargs) |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
498 |
except bzmysql._MySQLdb.MySQLError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
499 |
self.ui.note(_(b'failed query: %s %s\n') % (args, kwargs)) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
500 |
raise |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
501 |
|
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
502 |
def get_longdesc_id(self): |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
503 |
'''get identity of longdesc field''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
504 |
self.run(b'select fieldid from fielddefs where name = "longdesc"') |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
505 |
ids = self.cursor.fetchall() |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
506 |
if len(ids) != 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 |
raise error.Abort(_(b'unknown database schema')) |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
508 |
return ids[0][0] |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
509 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
510 |
def filter_real_bug_ids(self, bugs): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
511 |
'''filter not-existing bugs from set.''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
512 |
self.run( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
513 |
b'select bug_id from bugs where bug_id in %s' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
514 |
% bzmysql.sql_buglist(bugs.keys()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
515 |
) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
516 |
existing = [id for (id,) in self.cursor.fetchall()] |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
517 |
for id in bugs.keys(): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
518 |
if id not in existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
519 |
self.ui.status(_(b'bug %d does not exist\n') % id) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
520 |
del bugs[id] |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
521 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
522 |
def filter_cset_known_bug_ids(self, node, bugs): |
13799
d04fc5582772
bugzilla: keep bug IDs in set.
Jim Hague <jim.hague@acm.org>
parents:
13798
diff
changeset
|
523 |
'''filter bug ids that already refer to this changeset from set.''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
524 |
self.run( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
525 |
'''select bug_id from longdescs where |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
526 |
bug_id in %s and thetext like "%%%s%%"''' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
527 |
% (bzmysql.sql_buglist(bugs.keys()), short(node)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
528 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
529 |
for (id,) in self.cursor.fetchall(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
530 |
self.ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
531 |
_(b'bug %d already knows about changeset %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
532 |
% (id, short(node)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
533 |
) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
534 |
del bugs[id] |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
535 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
536 |
def notify(self, bugs, committer): |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
537 |
'''tell bugzilla to send mail.''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
538 |
self.ui.status(_(b'telling bugzilla to send mail:\n')) |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
539 |
(user, userid) = self.get_bugzilla_user(committer) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
540 |
for id in bugs.keys(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
541 |
self.ui.status(_(b' bug %s\n') % id) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
542 |
cmdfmt = self.ui.config(b'bugzilla', b'notify', self.default_notify) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
543 |
bzdir = self.ui.config(b'bugzilla', b'bzdir') |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
544 |
try: |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
545 |
# Backwards-compatible with old notify string, which |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
546 |
# took one string. This will throw with a new format |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
547 |
# string. |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
548 |
cmd = cmdfmt % id |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
549 |
except TypeError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
550 |
cmd = cmdfmt % {b'bzdir': bzdir, b'id': id, b'user': user} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
551 |
self.ui.note(_(b'running notify command %s\n') % cmd) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
552 |
fp = procutil.popen(b'(%s) 2>&1' % cmd, b'rb') |
37458
00e4bd97b095
procutil: always popen() in binary mode
Yuya Nishihara <yuya@tcha.org>
parents:
37120
diff
changeset
|
553 |
out = util.fromnativeeol(fp.read()) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
554 |
ret = fp.close() |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
555 |
if ret: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
556 |
self.ui.warn(out) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
557 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
558 |
_(b'bugzilla notify command %s') % procutil.explainexit(ret) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
559 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
560 |
self.ui.status(_(b'done\n')) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
561 |
|
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
562 |
def get_user_id(self, user): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
563 |
'''look up numeric bugzilla user id.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
564 |
try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
565 |
return self.user_ids[user] |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
566 |
except KeyError: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
567 |
try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
568 |
userid = int(user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
569 |
except ValueError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
570 |
self.ui.note(_(b'looking up user %s\n') % user) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
571 |
self.run( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
572 |
'''select userid from profiles |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
573 |
where login_name like %s''', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
574 |
user, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
575 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
576 |
all = self.cursor.fetchall() |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
577 |
if len(all) != 1: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
578 |
raise KeyError(user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
579 |
userid = int(all[0][0]) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
580 |
self.user_ids[user] = userid |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
581 |
return userid |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
582 |
|
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
583 |
def get_bugzilla_user(self, committer): |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
584 |
'''See if committer is a registered bugzilla user. Return |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
585 |
bugzilla username and userid if so. If not, return default |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
586 |
bugzilla username and userid.''' |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
587 |
user = self.map_committer(committer) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
588 |
try: |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
589 |
userid = self.get_user_id(user) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
590 |
except KeyError: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
591 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
592 |
defaultuser = self.ui.config(b'bugzilla', b'bzuser') |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
593 |
if not defaultuser: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
594 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
595 |
_(b'cannot find bugzilla user id for %s') % user |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
596 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
597 |
userid = self.get_user_id(defaultuser) |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
598 |
user = defaultuser |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
599 |
except KeyError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
600 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
601 |
_(b'cannot find bugzilla user id for %s or %s') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
602 |
% (user, defaultuser) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
603 |
) |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
604 |
return (user, userid) |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
605 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
606 |
def updatebug(self, bugid, newstate, text, committer): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
607 |
'''update bug state with comment text. |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
608 |
|
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
609 |
Try adding comment as committer of changeset, otherwise as |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
610 |
default bugzilla user.''' |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
611 |
if len(newstate) > 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
612 |
self.ui.warn(_(b"Bugzilla/MySQL cannot update bug state\n")) |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
613 |
|
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
614 |
(user, userid) = self.get_bugzilla_user(committer) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43380
diff
changeset
|
615 |
now = time.strftime('%Y-%m-%d %H:%M:%S') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
616 |
self.run( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
617 |
'''insert into longdescs |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
618 |
(bug_id, who, bug_when, thetext) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
619 |
values (%s, %s, %s, %s)''', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
620 |
(bugid, userid, now, text), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
621 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
622 |
self.run( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
623 |
'''insert into bugs_activity (bug_id, who, bug_when, fieldid) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
624 |
values (%s, %s, %s, %s)''', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
625 |
(bugid, userid, now, self.longdesc_id), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
626 |
) |
7493
518afef5e350
Fix Bugzilla integration to work with new Bugzilla 3.2.
Jim Hague <jim.hague@acm.org>
parents:
7369
diff
changeset
|
627 |
self.conn.commit() |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
628 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
629 |
|
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
630 |
class bzmysql_2_18(bzmysql): |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
631 |
'''support for bugzilla 2.18 series.''' |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
632 |
|
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
633 |
def __init__(self, ui): |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
634 |
bzmysql.__init__(self, ui) |
41759
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41343
diff
changeset
|
635 |
self.default_notify = ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
636 |
b"cd %(bzdir)s && perl -T contrib/sendbugmail.pl %(id)s %(user)s" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
637 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
638 |
|
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
639 |
|
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
640 |
class bzmysql_3_0(bzmysql_2_18): |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
641 |
'''support for bugzilla 3.0 series.''' |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
642 |
|
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
643 |
def __init__(self, ui): |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
644 |
bzmysql_2_18.__init__(self, ui) |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
645 |
|
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
646 |
def get_longdesc_id(self): |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
647 |
'''get identity of longdesc field''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
648 |
self.run(b'select id from fielddefs where name = "longdesc"') |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
649 |
ids = self.cursor.fetchall() |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
650 |
if len(ids) != 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
651 |
raise error.Abort(_(b'unknown database schema')) |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
652 |
return ids[0][0] |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
653 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
654 |
|
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
16881
diff
changeset
|
655 |
# Bugzilla via XMLRPC interface. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
656 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
657 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
658 |
class cookietransportrequest(object): |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
659 |
"""A Transport request method that retains cookies over its lifetime. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
660 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
661 |
The regular xmlrpclib transports ignore cookies. Which causes |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
662 |
a bit of a problem when you need a cookie-based login, as with |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
663 |
the Bugzilla XMLRPC interface prior to 4.4.3. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
664 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
665 |
So this is a helper for defining a Transport which looks for |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
666 |
cookies being set in responses and saves them to add to all future |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
667 |
requests. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
668 |
""" |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
669 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
670 |
# Inspiration drawn from |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
671 |
# http://blog.godson.in/2010/09/how-to-make-python-xmlrpclib-client.html |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
672 |
# http://www.itkovian.net/base/transport-class-for-pythons-xml-rpc-lib/ |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
673 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
674 |
cookies = [] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
675 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
676 |
def send_cookies(self, connection): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
677 |
if self.cookies: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
678 |
for cookie in self.cookies: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
679 |
connection.putheader(b"Cookie", cookie) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
680 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
681 |
def request(self, host, handler, request_body, verbose=0): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
682 |
self.verbose = verbose |
16193
b468cea3f29d
bugzilla: stop XMLRPC requests from requesting gzipped responses
Jim Hague <jim.hague@acm.org>
parents:
15870
diff
changeset
|
683 |
self.accept_gzip_encoding = False |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
684 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
685 |
# issue XML-RPC request |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
686 |
h = self.make_connection(host) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
687 |
if verbose: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
688 |
h.set_debuglevel(1) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
689 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
690 |
self.send_request(h, handler, request_body) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
691 |
self.send_host(h, host) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
692 |
self.send_cookies(h) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
693 |
self.send_user_agent(h) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
694 |
self.send_content(h, request_body) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
695 |
|
30478
f7d66746ec18
bugzilla: stop mentioning Pythons older than 2.6
Augie Fackler <augie@google.com>
parents:
29841
diff
changeset
|
696 |
# Deal with differences between Python 2.6 and 2.7. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
697 |
# In the former h is a HTTP(S). In the latter it's a |
30478
f7d66746ec18
bugzilla: stop mentioning Pythons older than 2.6
Augie Fackler <augie@google.com>
parents:
29841
diff
changeset
|
698 |
# HTTP(S)Connection. Luckily, the 2.6 implementation of |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
699 |
# HTTP(S) has an underlying HTTP(S)Connection, so extract |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
700 |
# that and use it. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
701 |
try: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
702 |
response = h.getresponse() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
703 |
except AttributeError: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
704 |
response = h._conn.getresponse() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
705 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
706 |
# Add any cookie definitions to our list. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
707 |
for header in response.msg.getallmatchingheaders(b"Set-Cookie"): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
708 |
val = header.split(b": ", 1)[1] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
709 |
cookie = val.split(b";", 1)[0] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
710 |
self.cookies.append(cookie) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
711 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
712 |
if response.status != 200: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
713 |
raise xmlrpclib.ProtocolError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
714 |
host + handler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
715 |
response.status, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
716 |
response.reason, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
717 |
response.msg.headers, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
718 |
) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
719 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
720 |
payload = response.read() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
721 |
parser, unmarshaller = self.getparser() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
722 |
parser.feed(payload) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
723 |
parser.close() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
724 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
725 |
return unmarshaller.close() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
726 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
727 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
728 |
# The explicit calls to the underlying xmlrpclib __init__() methods are |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
729 |
# necessary. The xmlrpclib.Transport classes are old-style classes, and |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
730 |
# it turns out their __init__() doesn't get called when doing multiple |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
731 |
# inheritance with a new-style class. |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
732 |
class cookietransport(cookietransportrequest, xmlrpclib.Transport): |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
733 |
def __init__(self, use_datetime=0): |
43115
4aa72cdf616f
py3: delete b'' prefix from safehasattr arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
734 |
if util.safehasattr(xmlrpclib.Transport, "__init__"): |
16649
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
735 |
xmlrpclib.Transport.__init__(self, use_datetime) |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
736 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
737 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
738 |
class cookiesafetransport(cookietransportrequest, xmlrpclib.SafeTransport): |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
739 |
def __init__(self, use_datetime=0): |
43115
4aa72cdf616f
py3: delete b'' prefix from safehasattr arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
740 |
if util.safehasattr(xmlrpclib.Transport, "__init__"): |
16649
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
741 |
xmlrpclib.SafeTransport.__init__(self, use_datetime) |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
742 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
743 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
744 |
class bzxmlrpc(bzaccess): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
745 |
"""Support for access to Bugzilla via the Bugzilla XMLRPC API. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
746 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
747 |
Requires a minimum Bugzilla version 3.4. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
748 |
""" |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
749 |
|
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
750 |
def __init__(self, ui): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
751 |
bzaccess.__init__(self, ui) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
752 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
753 |
bzweb = self.ui.config(b'bugzilla', b'bzurl') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
754 |
bzweb = bzweb.rstrip(b"/") + b"/xmlrpc.cgi" |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
755 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
756 |
user = self.ui.config(b'bugzilla', b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
757 |
passwd = self.ui.config(b'bugzilla', b'password') |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
758 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
759 |
self.fixstatus = self.ui.config(b'bugzilla', b'fixstatus') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
760 |
self.fixresolution = self.ui.config(b'bugzilla', b'fixresolution') |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
761 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
762 |
self.bzproxy = xmlrpclib.ServerProxy(bzweb, self.transport(bzweb)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
763 |
ver = self.bzproxy.Bugzilla.version()[b'version'].split(b'.') |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
764 |
self.bzvermajor = int(ver[0]) |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
765 |
self.bzverminor = int(ver[1]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
766 |
login = self.bzproxy.User.login( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
767 |
{b'login': user, b'password': passwd, b'restrict_login': True} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
768 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
769 |
self.bztoken = login.get(b'token', b'') |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
770 |
|
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
771 |
def transport(self, uri): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
772 |
if util.urlreq.urlparse(uri, b"http")[0] == b"https": |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
773 |
return cookiesafetransport() |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
774 |
else: |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
775 |
return cookietransport() |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
776 |
|
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
777 |
def get_bug_comments(self, id): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
778 |
"""Return a string with all comment text for a bug.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
779 |
c = self.bzproxy.Bug.comments( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
780 |
{b'ids': [id], b'include_fields': [b'text'], b'token': self.bztoken} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
781 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
782 |
return b''.join( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
783 |
[t[b'text'] for t in c[b'bugs'][b'%d' % id][b'comments']] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
784 |
) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
785 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
786 |
def filter_real_bug_ids(self, bugs): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
787 |
probe = self.bzproxy.Bug.get( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
788 |
{ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
789 |
b'ids': sorted(bugs.keys()), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
790 |
b'include_fields': [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
791 |
b'permissive': True, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
792 |
b'token': self.bztoken, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
793 |
} |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
794 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
795 |
for badbug in probe[b'faults']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
796 |
id = badbug[b'id'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
797 |
self.ui.status(_(b'bug %d does not exist\n') % id) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
798 |
del bugs[id] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
799 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
800 |
def filter_cset_known_bug_ids(self, node, bugs): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
801 |
for id in sorted(bugs.keys()): |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
802 |
if self.get_bug_comments(id).find(short(node)) != -1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
803 |
self.ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
804 |
_(b'bug %d already knows about changeset %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
805 |
% (id, short(node)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
806 |
) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
807 |
del bugs[id] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
808 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
809 |
def updatebug(self, bugid, newstate, text, committer): |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
810 |
args = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
811 |
if b'hours' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
812 |
args[b'work_time'] = newstate[b'hours'] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
813 |
|
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
814 |
if self.bzvermajor >= 4: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
815 |
args[b'ids'] = [bugid] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
816 |
args[b'comment'] = {b'body': text} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
817 |
if b'fix' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
818 |
args[b'status'] = self.fixstatus |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
819 |
args[b'resolution'] = self.fixresolution |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
820 |
args[b'token'] = self.bztoken |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
821 |
self.bzproxy.Bug.update(args) |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
822 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
823 |
if b'fix' in newstate: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
824 |
self.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
825 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
826 |
b"Bugzilla/XMLRPC needs Bugzilla 4.0 or later " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
827 |
b"to mark bugs fixed\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
828 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
829 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
830 |
args[b'id'] = bugid |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
831 |
args[b'comment'] = text |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
832 |
self.bzproxy.Bug.add_comment(args) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
833 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
834 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
835 |
class bzxmlrpcemail(bzxmlrpc): |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
836 |
"""Read data from Bugzilla via XMLRPC, send updates via email. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
837 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
838 |
Advantages of sending updates via email: |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
839 |
1. Comments can be added as any user, not just logged in user. |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
840 |
2. Bug statuses or other fields not accessible via XMLRPC can |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
841 |
potentially be updated. |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
842 |
|
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
843 |
There is no XMLRPC function to change bug status before Bugzilla |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
844 |
4.0, so bugs cannot be marked fixed via XMLRPC before Bugzilla 4.0. |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
845 |
But bugs can be marked fixed via email from 3.4 onwards. |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
846 |
""" |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
847 |
|
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
848 |
# The email interface changes subtly between 3.4 and 3.6. In 3.4, |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
849 |
# in-email fields are specified as '@<fieldname> = <value>'. In |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
850 |
# 3.6 this becomes '@<fieldname> <value>'. And fieldname @bug_id |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
851 |
# in 3.4 becomes @id in 3.6. 3.6 and 4.0 both maintain backwards |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
852 |
# compatibility, but rather than rely on this use the new format for |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
853 |
# 4.0 onwards. |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
854 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
855 |
def __init__(self, ui): |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
856 |
bzxmlrpc.__init__(self, ui) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
857 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
858 |
self.bzemail = self.ui.config(b'bugzilla', b'bzemail') |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
859 |
if not self.bzemail: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
860 |
raise error.Abort(_(b"configuration 'bzemail' missing")) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
861 |
mail.validateconfig(self.ui) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
862 |
|
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
863 |
def makecommandline(self, fieldname, value): |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
864 |
if self.bzvermajor >= 4: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
865 |
return b"@%s %s" % (fieldname, pycompat.bytestr(value)) |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
866 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
867 |
if fieldname == b"id": |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
868 |
fieldname = b"bug_id" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
869 |
return b"@%s = %s" % (fieldname, pycompat.bytestr(value)) |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
870 |
|
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
871 |
def send_bug_modify_email(self, bugid, commands, comment, committer): |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
872 |
'''send modification message to Bugzilla bug via email. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
873 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
874 |
The message format is documented in the Bugzilla email_in.pl |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
875 |
specification. commands is a list of command lines, comment is the |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
876 |
comment text. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
877 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
878 |
To stop users from crafting commit comments with |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
879 |
Bugzilla commands, specify the bug ID via the message body, rather |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
880 |
than the subject line, and leave a blank line after it. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
881 |
''' |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
882 |
user = self.map_committer(committer) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
883 |
matches = self.bzproxy.User.get( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
884 |
{b'match': [user], b'token': self.bztoken} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
885 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
886 |
if not matches[b'users']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
887 |
user = self.ui.config(b'bugzilla', b'user') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
888 |
matches = self.bzproxy.User.get( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
889 |
{b'match': [user], b'token': self.bztoken} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
890 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
891 |
if not matches[b'users']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
892 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
893 |
_(b"default bugzilla user %s email not found") % user |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
894 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
895 |
user = matches[b'users'][0][b'email'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
896 |
commands.append(self.makecommandline(b"id", bugid)) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
897 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
898 |
text = b"\n".join(commands) + b"\n\n" + comment |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
899 |
|
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
900 |
_charsets = mail._charsets(self.ui) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
901 |
user = mail.addressencode(self.ui, user, _charsets) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
902 |
bzemail = mail.addressencode(self.ui, self.bzemail, _charsets) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
903 |
msg = mail.mimeencode(self.ui, text, _charsets) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
904 |
msg[b'From'] = user |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
905 |
msg[b'To'] = bzemail |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
906 |
msg[b'Subject'] = mail.headencode( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
907 |
self.ui, b"Bug modification", _charsets |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
908 |
) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
909 |
sendmail = mail.connect(self.ui) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
910 |
sendmail(user, bzemail, msg.as_string()) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
911 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
912 |
def updatebug(self, bugid, newstate, text, committer): |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
913 |
cmds = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
914 |
if b'hours' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
915 |
cmds.append(self.makecommandline(b"work_time", newstate[b'hours'])) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
916 |
if b'fix' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
917 |
cmds.append(self.makecommandline(b"bug_status", self.fixstatus)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
918 |
cmds.append(self.makecommandline(b"resolution", self.fixresolution)) |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
919 |
self.send_bug_modify_email(bugid, cmds, text, committer) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
920 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
921 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
922 |
class NotFound(LookupError): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
923 |
pass |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
924 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
925 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
926 |
class bzrestapi(bzaccess): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
927 |
"""Read and write bugzilla data using the REST API available since |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
928 |
Bugzilla 5.0. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
929 |
""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
930 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
931 |
def __init__(self, ui): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
932 |
bzaccess.__init__(self, ui) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 |
bz = self.ui.config(b'bugzilla', b'bzurl') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 |
self.bzroot = b'/'.join([bz, b'rest']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
935 |
self.apikey = self.ui.config(b'bugzilla', b'apikey') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 |
self.user = self.ui.config(b'bugzilla', b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
937 |
self.passwd = self.ui.config(b'bugzilla', b'password') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
938 |
self.fixstatus = self.ui.config(b'bugzilla', b'fixstatus') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
939 |
self.fixresolution = self.ui.config(b'bugzilla', b'fixresolution') |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
940 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
941 |
def apiurl(self, targets, include_fields=None): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
942 |
url = b'/'.join([self.bzroot] + [pycompat.bytestr(t) for t in targets]) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
943 |
qv = {} |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
944 |
if self.apikey: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
945 |
qv[b'api_key'] = self.apikey |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
946 |
elif self.user and self.passwd: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
947 |
qv[b'login'] = self.user |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
948 |
qv[b'password'] = self.passwd |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
949 |
if include_fields: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
950 |
qv[b'include_fields'] = include_fields |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
951 |
if qv: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
952 |
url = b'%s?%s' % (url, util.urlreq.urlencode(qv)) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
953 |
return url |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
954 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
955 |
def _fetch(self, burl): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
956 |
try: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
957 |
resp = url.open(self.ui, burl) |
43380
579672b347d2
py3: define and use json.loads polyfill
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43115
diff
changeset
|
958 |
return pycompat.json_loads(resp.read()) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
959 |
except util.urlerr.httperror as inst: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
960 |
if inst.code == 401: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
961 |
raise error.Abort(_(b'authorization failed')) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
962 |
if inst.code == 404: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
963 |
raise NotFound() |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
964 |
else: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
965 |
raise |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
966 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
967 |
def _submit(self, burl, data, method=b'POST'): |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
968 |
data = json.dumps(data) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
969 |
if method == b'PUT': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
970 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
971 |
class putrequest(util.urlreq.request): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
972 |
def get_method(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
973 |
return b'PUT' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
974 |
|
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
975 |
request_type = putrequest |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
976 |
else: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
977 |
request_type = util.urlreq.request |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
978 |
req = request_type(burl, data, {b'Content-Type': b'application/json'}) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
979 |
try: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
980 |
resp = url.opener(self.ui).open(req) |
43380
579672b347d2
py3: define and use json.loads polyfill
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43115
diff
changeset
|
981 |
return pycompat.json_loads(resp.read()) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
982 |
except util.urlerr.httperror as inst: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
983 |
if inst.code == 401: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
984 |
raise error.Abort(_(b'authorization failed')) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
985 |
if inst.code == 404: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
986 |
raise NotFound() |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
987 |
else: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
988 |
raise |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
989 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
990 |
def filter_real_bug_ids(self, bugs): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
991 |
'''remove bug IDs that do not exist in Bugzilla from bugs.''' |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
992 |
badbugs = set() |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
993 |
for bugid in bugs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
994 |
burl = self.apiurl((b'bug', bugid), include_fields=b'status') |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
995 |
try: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
996 |
self._fetch(burl) |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
997 |
except NotFound: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
998 |
badbugs.add(bugid) |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
999 |
for bugid in badbugs: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1000 |
del bugs[bugid] |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1001 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1002 |
def filter_cset_known_bug_ids(self, node, bugs): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1003 |
'''remove bug IDs where node occurs in comment text from bugs.''' |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1004 |
sn = short(node) |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1005 |
for bugid in bugs.keys(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1006 |
burl = self.apiurl( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1007 |
(b'bug', bugid, b'comment'), include_fields=b'text' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1008 |
) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1009 |
result = self._fetch(burl) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1010 |
comments = result[b'bugs'][pycompat.bytestr(bugid)][b'comments'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1011 |
if any(sn in c[b'text'] for c in comments): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1012 |
self.ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1013 |
_(b'bug %d already knows about changeset %s\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1014 |
% (bugid, sn) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1015 |
) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1016 |
del bugs[bugid] |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1017 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1018 |
def updatebug(self, bugid, newstate, text, committer): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1019 |
'''update the specified bug. Add comment text and set new states. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1020 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1021 |
If possible add the comment as being from the committer of |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1022 |
the changeset. Otherwise use the default Bugzilla user. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1023 |
''' |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1024 |
bugmod = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1025 |
if b'hours' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1026 |
bugmod[b'work_time'] = newstate[b'hours'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1027 |
if b'fix' in newstate: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1028 |
bugmod[b'status'] = self.fixstatus |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1029 |
bugmod[b'resolution'] = self.fixresolution |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1030 |
if bugmod: |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1031 |
# if we have to change the bugs state do it here |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1032 |
bugmod[b'comment'] = { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1033 |
b'comment': text, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1034 |
b'is_private': False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1035 |
b'is_markdown': False, |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1036 |
} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1037 |
burl = self.apiurl((b'bug', bugid)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1038 |
self._submit(burl, bugmod, method=b'PUT') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1039 |
self.ui.debug(b'updated bug %s\n' % bugid) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1040 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1041 |
burl = self.apiurl((b'bug', bugid, b'comment')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1042 |
self._submit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1043 |
burl, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1044 |
{ |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1045 |
b'comment': text, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1046 |
b'is_private': False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1047 |
b'is_markdown': False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1048 |
}, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1049 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1050 |
self.ui.debug(b'added comment to bug %s\n' % bugid) |
30923
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1051 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1052 |
def notify(self, bugs, committer): |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1053 |
'''Force sending of Bugzilla notification emails. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1054 |
|
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1055 |
Only required if the access method does not trigger notification |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1056 |
emails automatically. |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1057 |
''' |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1058 |
pass |
78de43ab585f
bugzilla: add a rest api backend (usable with bugzilla 5.0+)
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
30478
diff
changeset
|
1059 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1060 |
|
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1061 |
class bugzilla(object): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1062 |
# supported versions of bugzilla. different versions have |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1063 |
# different schemas. |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1064 |
_versions = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1065 |
b'2.16': bzmysql, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1066 |
b'2.18': bzmysql_2_18, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1067 |
b'3.0': bzmysql_3_0, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1068 |
b'xmlrpc': bzxmlrpc, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1069 |
b'xmlrpc+email': bzxmlrpcemail, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1070 |
b'restapi': bzrestapi, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1071 |
} |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1072 |
|
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1073 |
def __init__(self, ui, repo): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1074 |
self.ui = ui |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1075 |
self.repo = repo |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1076 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1077 |
bzversion = self.ui.config(b'bugzilla', b'version') |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1078 |
try: |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1079 |
bzclass = bugzilla._versions[bzversion] |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1080 |
except KeyError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1081 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1082 |
_(b'bugzilla version %s not supported') % bzversion |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1083 |
) |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1084 |
self.bzdriver = bzclass(self.ui) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1085 |
|
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1086 |
self.bug_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1087 |
self.ui.config(b'bugzilla', b'regexp'), re.IGNORECASE |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1088 |
) |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1089 |
self.fix_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1090 |
self.ui.config(b'bugzilla', b'fixregexp'), re.IGNORECASE |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1091 |
) |
41343
7370f302be71
py3: port test-bugzilla.t to Python 3
Augie Fackler <augie@google.com>
parents:
37463
diff
changeset
|
1092 |
self.split_re = re.compile(br'\D+') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1093 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1094 |
def find_bugs(self, ctx): |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1095 |
'''return bugs dictionary created from commit comment. |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1096 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1097 |
Extract bug info from changeset comments. Filter out any that are |
13799
d04fc5582772
bugzilla: keep bug IDs in set.
Jim Hague <jim.hague@acm.org>
parents:
13798
diff
changeset
|
1098 |
not known to Bugzilla, and any that already have a reference to |
d04fc5582772
bugzilla: keep bug IDs in set.
Jim Hague <jim.hague@acm.org>
parents:
13798
diff
changeset
|
1099 |
the given changeset in their comments. |
d04fc5582772
bugzilla: keep bug IDs in set.
Jim Hague <jim.hague@acm.org>
parents:
13798
diff
changeset
|
1100 |
''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1101 |
start = 0 |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1102 |
hours = 0.0 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1103 |
bugs = {} |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1104 |
bugmatch = self.bug_re.search(ctx.description(), start) |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1105 |
fixmatch = self.fix_re.search(ctx.description(), start) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1106 |
while True: |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1107 |
bugattribs = {} |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1108 |
if not bugmatch and not fixmatch: |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1109 |
break |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1110 |
if not bugmatch: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1111 |
m = fixmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1112 |
elif not fixmatch: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1113 |
m = bugmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1114 |
else: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1115 |
if bugmatch.start() < fixmatch.start(): |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1116 |
m = bugmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1117 |
else: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1118 |
m = fixmatch |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1119 |
start = m.end() |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1120 |
if m is bugmatch: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1121 |
bugmatch = self.bug_re.search(ctx.description(), start) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1122 |
if b'fix' in bugattribs: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1123 |
del bugattribs[b'fix'] |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1124 |
else: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1125 |
fixmatch = self.fix_re.search(ctx.description(), start) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1126 |
bugattribs[b'fix'] = None |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
1127 |
|
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1128 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1129 |
ids = m.group(b'ids') |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1130 |
except IndexError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1131 |
ids = m.group(1) |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1132 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1133 |
hours = float(m.group(b'hours')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1134 |
bugattribs[b'hours'] = hours |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1135 |
except IndexError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1136 |
pass |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1137 |
except TypeError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1138 |
pass |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1139 |
except ValueError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1140 |
self.ui.status(_(b"%s: invalid hours\n") % m.group(b'hours')) |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1141 |
|
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1142 |
for id in self.split_re.split(ids): |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
1143 |
if not id: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
1144 |
continue |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
1145 |
bugs[int(id)] = bugattribs |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1146 |
if bugs: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1147 |
self.bzdriver.filter_real_bug_ids(bugs) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1148 |
if bugs: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1149 |
self.bzdriver.filter_cset_known_bug_ids(ctx.node(), bugs) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1150 |
return bugs |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1151 |
|
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1152 |
def update(self, bugid, newstate, ctx): |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1153 |
'''update bugzilla bug with reference to changeset.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1154 |
|
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1155 |
def webroot(root): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1156 |
'''strip leading prefix of repo root and turn into |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1157 |
url-safe path.''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1158 |
count = int(self.ui.config(b'bugzilla', b'strip')) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1159 |
root = util.pconvert(root) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1160 |
while count > 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1161 |
c = root.find(b'/') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1162 |
if c == -1: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1163 |
break |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1164 |
root = root[c + 1 :] |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1165 |
count -= 1 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1166 |
return root |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1167 |
|
28950
9e1c9f016b72
bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
28091
diff
changeset
|
1168 |
mapfile = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1169 |
tmpl = self.ui.config(b'bugzilla', b'template') |
28950
9e1c9f016b72
bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
28091
diff
changeset
|
1170 |
if not tmpl: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1171 |
mapfile = self.ui.config(b'bugzilla', b'style') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1172 |
if not mapfile and not tmpl: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1173 |
tmpl = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1174 |
b'changeset {node|short} in repo {root} refers ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1175 |
b'to bug {bug}.\ndetails:\n\t{desc|tabindent}' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1176 |
) |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35151
diff
changeset
|
1177 |
spec = logcmdutil.templatespec(tmpl, mapfile) |
35954
386c1e45e671
logcmdutil: drop default arguments from changesetdisplayer/templater() calls
Yuya Nishihara <yuya@tcha.org>
parents:
35888
diff
changeset
|
1178 |
t = logcmdutil.changesettemplater(self.ui, self.repo, spec) |
3741
0897bf8d54c7
update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1179 |
self.ui.pushbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1180 |
t.show( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1181 |
ctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1182 |
changes=ctx.changeset(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1183 |
bug=pycompat.bytestr(bugid), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1184 |
hgweb=self.ui.config(b'web', b'baseurl'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1185 |
root=self.repo.root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1186 |
webroot=webroot(self.repo.root), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1187 |
) |
3741
0897bf8d54c7
update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1188 |
data = self.ui.popbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1189 |
self.bzdriver.updatebug( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1190 |
bugid, newstate, data, stringutil.email(ctx.user()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1191 |
) |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1192 |
|
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1193 |
def notify(self, bugs, committer): |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1194 |
'''ensure Bugzilla users are notified of bug change.''' |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
1195 |
self.bzdriver.notify(bugs, committer) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1196 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1197 |
|
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1198 |
def hook(ui, repo, hooktype, node=None, **kwargs): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1199 |
'''add comment to bugzilla for each changeset that refers to a |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1200 |
bugzilla bug id. only add a comment once per bug, so same change |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1201 |
seen multiple times does not fill bug with duplicate data.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1202 |
if node is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1203 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1204 |
_(b'hook type %s does not pass a changeset id') % hooktype |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
1205 |
) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1206 |
try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1207 |
bz = bugzilla(ui, repo) |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6548
diff
changeset
|
1208 |
ctx = repo[node] |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1209 |
bugs = bz.find_bugs(ctx) |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1210 |
if bugs: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1211 |
for bug in bugs: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
1212 |
bz.update(bug, bugs[bug], ctx) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35954
diff
changeset
|
1213 |
bz.notify(bugs, stringutil.email(ctx.user())) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25186
diff
changeset
|
1214 |
except Exception as e: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1215 |
raise error.Abort(_(b'Bugzilla error: %s') % e) |