Mercurial > hg
annotate hgext/bugzilla.py @ 28455:412ee35a8005
chg: do not write pidfile
Current pidfile logic will only keep the pid of the newest server, which is
not very useful if we want to kill all servers, and will become outdated if
the server auto exits after being idle for too long.
Besides, the server-side pidfile writing logic runs before chgserver gets
confighash so it's not trivial to append confighash to pidfile basename like
we did for socket file.
This patch removes --pidfile from the command starting chgserver and switches
to an alternative way (unlink socket file) to stop the server.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 10 Mar 2016 00:19:55 +0000 |
parents | 2f0384242b35 |
children | 9e1c9f016b72 |
rev | line source |
---|---|
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 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
18 Three basic modes of access to Bugzilla are provided: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
19 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
20 1. Access via the Bugzilla XMLRPC interface. Requires Bugzilla 3.4 or later. |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
21 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
22 2. Check data via the Bugzilla XMLRPC interface and submit bug change |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
23 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
|
24 |
13896
3b4025dcb223
bugzilla: more documentation formatting fixups
Jim Hague <jim.hague@acm.org>
parents:
13884
diff
changeset
|
25 3. 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
|
26 using MySQL are supported. Requires Python MySQLdb. |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
27 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 permission to read Bugzilla configuration details and the necessary |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 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
|
37 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 |
13871
22d200e49b10
bugzilla: more documentation fixes
Jim Hague <jim.hague@acm.org>
parents:
13870
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 user, so the comment appears to come from the Mercurial user. In the event |
17534 | 48 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
|
49 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
|
50 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
|
51 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
|
52 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
53 Configuration items common to all access modes: |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
54 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
55 bugzilla.version |
17537 | 56 The access type to use. Values recognized are: |
13871
22d200e49b10
bugzilla: more documentation fixes
Jim Hague <jim.hague@acm.org>
parents:
13870
diff
changeset
|
57 |
13883
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
58 :``xmlrpc``: Bugzilla XMLRPC interface. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
59 :``xmlrpc+email``: Bugzilla XMLRPC and email interfaces. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
60 :``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
|
61 :``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
|
62 including 3.0. |
fc83d2ca9cfb
bugzilla: fix reST error introduced in 22d200e49b10
Martin Geisler <mg@aragost.com>
parents:
13871
diff
changeset
|
63 :``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
|
64 including 2.18. |
7985
0edca606c0f1
bugzilla: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7762
diff
changeset
|
65 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
66 bugzilla.regexp |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 "()" 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
|
73 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
|
74 ``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
|
75 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
|
76 ``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
|
77 |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
78 bugzilla.fixregexp |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 "()" 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
|
85 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
|
86 ``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
|
87 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
|
88 ``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
|
89 |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
90 bugzilla.fixstatus |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
91 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
|
92 |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
93 bugzilla.fixresolution |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
94 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
|
95 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
96 bugzilla.style |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
97 The style file to use when formatting comments. |
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
98 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
99 bugzilla.template |
9252
b03aa86f4c10
bugzilla: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9204
diff
changeset
|
100 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
|
101 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
|
102 extension specifies: |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
103 |
13884
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
104 :``{bug}``: The Bugzilla bug ID. |
773a833ddbc6
bugzilla: convert a verbatim block to a field list
Martin Geisler <mg@aragost.com>
parents:
13883
diff
changeset
|
105 :``{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
|
106 :``{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
|
107 :``{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
|
108 |
13842
4cffce61bd92
bugzilla: fix bad reST markup
Martin Geisler <mg@aragost.com>
parents:
13841
diff
changeset
|
109 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
|
110 {bug}.\\ndetails:\\n\\t{desc|tabindent}`` |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
111 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
112 bugzilla.strip |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
113 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
|
114 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
|
115 ``{webroot}``. For example, a repository with ``{root}`` |
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
116 ``/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
|
117 ``{webroot}`` of ``my-project``. Default 0. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
118 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
119 web.baseurl |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
120 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
|
121 templates as ``{hgweb}``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
122 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
123 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
|
124 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 line:: |
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
129 |
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
130 committer = Bugzilla user |
135bed43e20c
bugzilla: show usermap syntax more clearly
Martin Geisler <mg@aragost.com>
parents:
13834
diff
changeset
|
131 |
13896
3b4025dcb223
bugzilla: more documentation formatting fixups
Jim Hague <jim.hague@acm.org>
parents:
13884
diff
changeset
|
132 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
|
133 |
13836
ed15922af2f9
bugzilla: markup section names as literal text
Martin Geisler <mg@aragost.com>
parents:
13835
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
138 XMLRPC access mode configuration: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
139 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
140 bugzilla.bzurl |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
141 The base URL for the Bugzilla installation. |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
142 Default ``http://localhost/bugzilla``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
143 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
144 bugzilla.user |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
145 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
|
146 ``bugs``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
147 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
148 bugzilla.password |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
149 The password for Bugzilla login. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
150 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
151 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
|
152 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
|
153 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
154 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
|
155 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
|
156 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
157 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
|
158 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
|
159 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
160 MySQL access mode configuration: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
161 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
162 bugzilla.host |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
163 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
|
164 Default ``localhost``. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
165 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
166 bugzilla.db |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
167 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
|
168 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
169 bugzilla.user |
13841
367805c848e5
bugzilla: markup literal text as such
Martin Geisler <mg@aragost.com>
parents:
13837
diff
changeset
|
170 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
|
171 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
172 bugzilla.password |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
173 Password to use to access MySQL server. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
174 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
175 bugzilla.timeout |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
176 Database connection timeout (seconds). Default 5. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
177 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
178 bugzilla.bzuser |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
179 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
|
180 committer cannot be found as a Bugzilla user. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
181 |
13833
64ad07dff0a8
bugzilla: prefix each config option with section
Martin Geisler <mg@aragost.com>
parents:
13832
diff
changeset
|
182 bugzilla.bzdir |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
183 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
|
184 ``/var/www/html/bugzilla``. |
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.notify |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 |
9203
e4dbd49b88a9
bugzilla: reformat list of configuration options
Martin Geisler <mg@lazybytes.net>
parents:
9054
diff
changeset
|
193 Activating the extension:: |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
194 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
195 [extensions] |
10112
703db37d186b
hgext: enable extensions without "hgext." prefix in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9252
diff
changeset
|
196 bugzilla = |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
197 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
198 [hooks] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
199 # 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
|
200 incoming.bugzilla = python:hgext.bugzilla.hook |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
201 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
202 Example configurations: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
203 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
204 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
|
205 ``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
|
206 ``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
|
207 collection of Mercurial repositories in ``/var/local/hg/repos/``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
208 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
|
209 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
210 [bugzilla] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
211 bzurl=http://my-project.org/bugzilla |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
212 user=bugmail@my-project.org |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
213 password=plugh |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
214 version=xmlrpc |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
215 template=Changeset {node|short} in {root|basename}. |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
216 {hgweb}/{webroot}/rev/{node|short}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
217 {desc}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
218 strip=5 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
219 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
220 [web] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
221 baseurl=http://my-project.org/hg |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
222 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
223 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
|
224 ``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
|
225 ``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
|
226 collection of Mercurial repositories in ``/var/local/hg/repos/``, |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
227 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
|
228 are sent to the Bugzilla email address |
13854
5ed036e42fd9
bugzilla: fix documentation typo
Patrick Mezard <pmezard@gmail.com>
parents:
13842
diff
changeset
|
229 ``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
|
230 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
231 [bugzilla] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
232 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
|
233 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
|
234 password=plugh |
21842
fd2527d9b995
bugzilla: correct config documentation error
Jim Hague <jim.hague@acm.org>
parents:
21542
diff
changeset
|
235 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
|
236 bzemail=bugzilla@my-project.org |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
237 template=Changeset {node|short} in {root|basename}. |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
238 {hgweb}/{webroot}/rev/{node|short}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
239 {desc}\\n |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
240 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
|
241 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
242 [web] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
243 baseurl=http://my-project.org/hg |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
244 |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
245 [usermap] |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
246 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
|
247 |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
248 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
|
249 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
|
250 the Bugzilla database name is ``bugs`` and MySQL is |
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
251 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
|
252 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
|
253 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
|
254 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
255 [bugzilla] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
256 host=localhost |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
257 password=XYZZY |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
258 version=3.0 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
259 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
|
260 bzdir=/opt/bugzilla-3.2 |
9204
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
261 template=Changeset {node|short} in {root|basename}. |
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
262 {hgweb}/{webroot}/rev/{node|short}\\n |
8d59e43854d9
bugzilla: wrap example template line
Martin Geisler <mg@lazybytes.net>
parents:
9203
diff
changeset
|
263 {desc}\\n |
7504
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
264 strip=5 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
265 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
266 [web] |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
267 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
|
268 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
269 [usermap] |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
270 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
|
271 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
272 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
|
273 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
274 Changeset 3b16791d6642 in repository-name. |
13870
ce066d424bba
bugzilla: correct sample configurations
Jim Hague <jim.hague@acm.org>
parents:
13854
diff
changeset
|
275 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
|
276 |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
277 Changeset commit comment. Bug 1234. |
d8cd79fbed3c
Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents:
7493
diff
changeset
|
278 ''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
279 |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
280 from __future__ import absolute_import |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
281 |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
282 import re |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
283 import time |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
284 import urlparse |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
285 import xmlrpclib |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
286 |
3891 | 287 from mercurial.i18n import _ |
6211
f89fd07fc51d
Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents:
5975
diff
changeset
|
288 from mercurial.node import short |
28091
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
289 from mercurial import ( |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
290 cmdutil, |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
291 error, |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
292 mail, |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
293 util, |
2f0384242b35
bugzilla: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
294 ) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
295 |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24987
diff
changeset
|
296 # Note for extension authors: ONLY specify testedwith = 'internal' for |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24987
diff
changeset
|
297 # 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
|
298 # 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
|
299 # leave the attribute unspecified. |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16683
diff
changeset
|
300 testedwith = 'internal' |
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16683
diff
changeset
|
301 |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
302 class bzaccess(object): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
303 '''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
|
304 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
305 def __init__(self, ui): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
306 self.ui = ui |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
307 usermap = self.ui.config('bugzilla', 'usermap') |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
308 if usermap: |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
309 self.ui.readconfig(usermap, sections=['usermap']) |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
310 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
311 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
|
312 '''map name of committer to Bugzilla user name.''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
313 for committer, bzuser in self.ui.configitems('usermap'): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
314 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
|
315 return bzuser |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
316 return user |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
317 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
318 # 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
|
319 # |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
320 # 'bugs' is a dict keyed on bug id, where values are a dict holding |
17534 | 321 # 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
|
322 # |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
323 # '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
|
324 # '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
|
325 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
326 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
|
327 '''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
|
328 pass |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
329 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
330 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
|
331 '''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
|
332 pass |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
333 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
334 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
|
335 '''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
|
336 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
337 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
|
338 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
|
339 ''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
340 pass |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
341 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
342 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
|
343 '''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
|
344 |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
345 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
|
346 emails automatically. |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
347 ''' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
348 pass |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
349 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
350 # 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
|
351 class bzmysql(bzaccess): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
352 '''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
|
353 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
354 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
|
355 |
16226
674ecd23c42c
bugzilla: correct comment typo
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
356 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
|
357 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
|
358 ''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
359 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
360 @staticmethod |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
361 def sql_buglist(ids): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
362 '''return SQL-friendly list of bug ids''' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
363 return '(' + ','.join(map(str, ids)) + ')' |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
364 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
365 _MySQLdb = None |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
366 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
367 def __init__(self, ui): |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
368 try: |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
369 import MySQLdb as mysql |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
370 bzmysql._MySQLdb = mysql |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25186
diff
changeset
|
371 except ImportError as err: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
372 raise error.Abort(_('python mysql support not available: %s') % err) |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
373 |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
374 bzaccess.__init__(self, ui) |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
375 |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
376 host = self.ui.config('bugzilla', 'host', 'localhost') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
377 user = self.ui.config('bugzilla', 'user', 'bugs') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
378 passwd = self.ui.config('bugzilla', 'password') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
379 db = self.ui.config('bugzilla', 'db', 'bugs') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
380 timeout = int(self.ui.config('bugzilla', 'timeout', 5)) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
381 self.ui.note(_('connecting to %s:%s as %s, password %s\n') % |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
382 (host, db, user, '*' * len(passwd))) |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
383 self.conn = bzmysql._MySQLdb.connect(host=host, |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
384 user=user, passwd=passwd, |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
385 db=db, |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
386 connect_timeout=timeout) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
387 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
|
388 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
|
389 self.user_ids = {} |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
390 self.default_notify = "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
|
391 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
392 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
|
393 '''run a query.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
394 self.ui.note(_('query: %s %s\n') % (args, kwargs)) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
395 try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
396 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
|
397 except bzmysql._MySQLdb.MySQLError: |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
398 self.ui.note(_('failed query: %s %s\n') % (args, kwargs)) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
399 raise |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
400 |
7019
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
401 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
|
402 '''get identity of longdesc field''' |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
403 self.run('select fieldid from fielddefs where name = "longdesc"') |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
404 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
|
405 if len(ids) != 1: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
406 raise error.Abort(_('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
|
407 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
|
408 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
409 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
|
410 '''filter not-existing bugs from set.''' |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
411 self.run('select bug_id from bugs where bug_id in %s' % |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
412 bzmysql.sql_buglist(bugs.keys())) |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
413 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
|
414 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
|
415 if id not in existing: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
416 self.ui.status(_('bug %d does not exist\n') % id) |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
417 del bugs[id] |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
418 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
419 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
|
420 '''filter bug ids that already refer to this changeset from set.''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
421 self.run('''select bug_id from longdescs where |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
422 bug_id in %s and thetext like "%%%s%%"''' % |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
423 (bzmysql.sql_buglist(bugs.keys()), short(node))) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
424 for (id,) in self.cursor.fetchall(): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
425 self.ui.status(_('bug %d already knows about changeset %s\n') % |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
426 (id, short(node))) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
427 del bugs[id] |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
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 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
|
430 '''tell bugzilla to send mail.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
431 self.ui.status(_('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
|
432 (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
|
433 for id in bugs.keys(): |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
434 self.ui.status(_(' bug %s\n') % id) |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
435 cmdfmt = self.ui.config('bugzilla', 'notify', self.default_notify) |
16683 | 436 bzdir = self.ui.config('bugzilla', 'bzdir', |
437 '/var/www/html/bugzilla') | |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
438 try: |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
439 # 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
|
440 # 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
|
441 # string. |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
442 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
|
443 except TypeError: |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
444 cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user} |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
445 self.ui.note(_('running notify command %s\n') % cmd) |
6548
962eb403165b
replace usage of os.popen() with util.popen()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6211
diff
changeset
|
446 fp = util.popen('(%s) 2>&1' % cmd) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
447 out = fp.read() |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
448 ret = fp.close() |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
449 if ret: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
450 self.ui.warn(out) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
451 raise error.Abort(_('bugzilla notify command %s') % |
14234
600e64004eb5
rename explain_exit to explainexit
Adrian Buehlmann <adrian@cadifra.com>
parents:
13896
diff
changeset
|
452 util.explainexit(ret)[0]) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
453 self.ui.status(_('done\n')) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
454 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
455 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
|
456 '''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
|
457 try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
458 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
|
459 except KeyError: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
460 try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
461 userid = int(user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
462 except ValueError: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
463 self.ui.note(_('looking up user %s\n') % user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
464 self.run('''select userid from profiles |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
465 where login_name like %s''', user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
466 all = self.cursor.fetchall() |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
467 if len(all) != 1: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
468 raise KeyError(user) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
469 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
|
470 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
|
471 return userid |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
472 |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
473 def get_bugzilla_user(self, committer): |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
474 '''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
|
475 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
|
476 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
|
477 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
|
478 try: |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
479 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
|
480 except KeyError: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
481 try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
482 defaultuser = self.ui.config('bugzilla', 'bzuser') |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
483 if not defaultuser: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
484 raise error.Abort(_('cannot find bugzilla user id for %s') % |
2306
4c67ba93560b
bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2239
diff
changeset
|
485 user) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
486 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
|
487 user = defaultuser |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
488 except KeyError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
489 raise error.Abort(_('cannot find bugzilla user id for %s or %s') |
16683 | 490 % (user, defaultuser)) |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
491 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
|
492 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
493 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
|
494 '''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
|
495 |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
496 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
|
497 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
|
498 if len(newstate) > 0: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
499 self.ui.warn(_("Bugzilla/MySQL cannot update bug state\n")) |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
500 |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
501 (user, userid) = self.get_bugzilla_user(committer) |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
502 now = time.strftime('%Y-%m-%d %H:%M:%S') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
503 self.run('''insert into longdescs |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
504 (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
|
505 values (%s, %s, %s, %s)''', |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
506 (bugid, userid, now, text)) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
507 self.run('''insert into bugs_activity (bug_id, who, bug_when, fieldid) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
508 values (%s, %s, %s, %s)''', |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
509 (bugid, userid, now, self.longdesc_id)) |
7493
518afef5e350
Fix Bugzilla integration to work with new Bugzilla 3.2.
Jim Hague <jim.hague@acm.org>
parents:
7369
diff
changeset
|
510 self.conn.commit() |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
511 |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
512 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
|
513 '''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
|
514 |
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
515 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
|
516 bzmysql.__init__(self, ui) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
517 self.default_notify = \ |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
518 "cd %(bzdir)s && perl -T contrib/sendbugmail.pl %(id)s %(user)s" |
7618
6c89dd0a7797
Bugzilla 2.18 and on use contrib/sendbugmail.pl, not processmail.
Jim Hague <jim.hague@acm.org>
parents:
7504
diff
changeset
|
519 |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
520 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
|
521 '''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
|
522 |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
523 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
|
524 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
|
525 |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
526 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
|
527 '''get identity of longdesc field''' |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
528 self.run('select id from fielddefs where name = "longdesc"') |
6b1ece890f9a
Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents:
6762
diff
changeset
|
529 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
|
530 if len(ids) != 1: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
531 raise error.Abort(_('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
|
532 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
|
533 |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
16881
diff
changeset
|
534 # Bugzilla via XMLRPC interface. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
535 |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
536 class cookietransportrequest(object): |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
537 """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
|
538 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
539 The regular xmlrpclib transports ignore cookies. Which causes |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
540 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
|
541 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
|
542 |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
543 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
|
544 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
|
545 requests. |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
546 """ |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
547 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
548 # Inspiration drawn from |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
549 # 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
|
550 # 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
|
551 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
552 cookies = [] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
553 def send_cookies(self, connection): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
554 if self.cookies: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
555 for cookie in self.cookies: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
556 connection.putheader("Cookie", cookie) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
557 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
558 def request(self, host, handler, request_body, verbose=0): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
559 self.verbose = verbose |
16193
b468cea3f29d
bugzilla: stop XMLRPC requests from requesting gzipped responses
Jim Hague <jim.hague@acm.org>
parents:
15870
diff
changeset
|
560 self.accept_gzip_encoding = False |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
561 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
562 # issue XML-RPC request |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
563 h = self.make_connection(host) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
564 if verbose: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
565 h.set_debuglevel(1) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
566 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
567 self.send_request(h, handler, request_body) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
568 self.send_host(h, host) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
569 self.send_cookies(h) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
570 self.send_user_agent(h) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
571 self.send_content(h, request_body) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
572 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
573 # Deal with differences between Python 2.4-2.6 and 2.7. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
574 # In the former h is a HTTP(S). In the latter it's a |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
575 # HTTP(S)Connection. Luckily, the 2.4-2.6 implementation of |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
576 # 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
|
577 # that and use it. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
578 try: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
579 response = h.getresponse() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
580 except AttributeError: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
581 response = h._conn.getresponse() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
582 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
583 # Add any cookie definitions to our list. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
584 for header in response.msg.getallmatchingheaders("Set-Cookie"): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
585 val = header.split(": ", 1)[1] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
586 cookie = val.split(";", 1)[0] |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
587 self.cookies.append(cookie) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
588 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
589 if response.status != 200: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
590 raise xmlrpclib.ProtocolError(host + handler, response.status, |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
591 response.reason, response.msg.headers) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
592 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
593 payload = response.read() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
594 parser, unmarshaller = self.getparser() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
595 parser.feed(payload) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
596 parser.close() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
597 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
598 return unmarshaller.close() |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
599 |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
600 # 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
|
601 # 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
|
602 # 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
|
603 # 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
|
604 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
|
605 def __init__(self, use_datetime=0): |
16649
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
606 if util.safehasattr(xmlrpclib.Transport, "__init__"): |
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
607 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
|
608 |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
609 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
|
610 def __init__(self, use_datetime=0): |
16649
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
611 if util.safehasattr(xmlrpclib.Transport, "__init__"): |
822e75386c16
bugzilla: fix transport initialization on python 2.4
Steven Stallion <sstallion@gmail.com>
parents:
16227
diff
changeset
|
612 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
|
613 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
614 class bzxmlrpc(bzaccess): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
615 """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
|
616 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
617 Requires a minimum Bugzilla version 3.4. |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
618 """ |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
619 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
620 def __init__(self, ui): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
621 bzaccess.__init__(self, ui) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
622 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
623 bzweb = self.ui.config('bugzilla', 'bzurl', |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
624 'http://localhost/bugzilla/') |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
625 bzweb = bzweb.rstrip("/") + "/xmlrpc.cgi" |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
626 |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
627 user = self.ui.config('bugzilla', 'user', 'bugs') |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
628 passwd = self.ui.config('bugzilla', 'password') |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
629 |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
630 self.fixstatus = self.ui.config('bugzilla', 'fixstatus', 'RESOLVED') |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
631 self.fixresolution = self.ui.config('bugzilla', 'fixresolution', |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
632 'FIXED') |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
633 |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
634 self.bzproxy = xmlrpclib.ServerProxy(bzweb, self.transport(bzweb)) |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
635 ver = self.bzproxy.Bugzilla.version()['version'].split('.') |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
636 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
|
637 self.bzverminor = int(ver[1]) |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
638 login = self.bzproxy.User.login({'login': user, 'password': passwd, |
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
639 'restrict_login': True}) |
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
640 self.bztoken = login.get('token', '') |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
641 |
15870
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
642 def transport(self, uri): |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
643 if urlparse.urlparse(uri, "http")[0] == "https": |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
644 return cookiesafetransport() |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
645 else: |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
646 return cookietransport() |
f4c859293ed4
bugzilla: make XMLRPC interface support http and https access
Jim Hague <jim.hague@acm.org>
parents:
14619
diff
changeset
|
647 |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
648 def get_bug_comments(self, id): |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
649 """Return a string with all comment text for a bug.""" |
20673
37cde285b89c
bugzilla: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20667
diff
changeset
|
650 c = self.bzproxy.Bug.comments({'ids': [id], |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
651 'include_fields': ['text'], |
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
652 'token': self.bztoken}) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
653 return ''.join([t['text'] for t in c['bugs'][str(id)]['comments']]) |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
654 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
655 def filter_real_bug_ids(self, bugs): |
20673
37cde285b89c
bugzilla: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20667
diff
changeset
|
656 probe = self.bzproxy.Bug.get({'ids': sorted(bugs.keys()), |
37cde285b89c
bugzilla: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20667
diff
changeset
|
657 'include_fields': [], |
37cde285b89c
bugzilla: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20667
diff
changeset
|
658 'permissive': True, |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
659 'token': self.bztoken, |
20673
37cde285b89c
bugzilla: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20667
diff
changeset
|
660 }) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
661 for badbug in probe['faults']: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
662 id = badbug['id'] |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
663 self.ui.status(_('bug %d does not exist\n') % id) |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
664 del bugs[id] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
665 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
666 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
|
667 for id in sorted(bugs.keys()): |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
668 if self.get_bug_comments(id).find(short(node)) != -1: |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
669 self.ui.status(_('bug %d already knows about changeset %s\n') % |
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
670 (id, short(node))) |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
671 del bugs[id] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
672 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
673 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
|
674 args = {} |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
675 if 'hours' in newstate: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
676 args['work_time'] = newstate['hours'] |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
677 |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
678 if self.bzvermajor >= 4: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
679 args['ids'] = [bugid] |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
680 args['comment'] = {'body' : text} |
16876
fdc879042414
bugzilla: stop bugs always being marked as fixed in xmlrpc (issue3484)
Jim Hague <jim.hague@acm.org>
parents:
16649
diff
changeset
|
681 if 'fix' in newstate: |
fdc879042414
bugzilla: stop bugs always being marked as fixed in xmlrpc (issue3484)
Jim Hague <jim.hague@acm.org>
parents:
16649
diff
changeset
|
682 args['status'] = self.fixstatus |
fdc879042414
bugzilla: stop bugs always being marked as fixed in xmlrpc (issue3484)
Jim Hague <jim.hague@acm.org>
parents:
16649
diff
changeset
|
683 args['resolution'] = self.fixresolution |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
684 args['token'] = self.bztoken |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
685 self.bzproxy.Bug.update(args) |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
686 else: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
687 if 'fix' in newstate: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
688 self.ui.warn(_("Bugzilla/XMLRPC needs Bugzilla 4.0 or later " |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
689 "to mark bugs fixed\n")) |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
690 args['id'] = bugid |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
691 args['comment'] = text |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
692 self.bzproxy.Bug.add_comment(args) |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
693 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
694 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
|
695 """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
|
696 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
697 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
|
698 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
|
699 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
|
700 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
|
701 |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 """ |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
706 |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
707 # 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
|
708 # 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
|
709 # 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
|
710 # 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
|
711 # 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
|
712 # 4.0 onwards. |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
713 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
714 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
|
715 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
|
716 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
717 self.bzemail = self.ui.config('bugzilla', 'bzemail') |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
718 if not self.bzemail: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
719 raise error.Abort(_("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
|
720 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
|
721 |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
722 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
|
723 if self.bzvermajor >= 4: |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
724 return "@%s %s" % (fieldname, str(value)) |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
725 else: |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
726 if fieldname == "id": |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
727 fieldname = "bug_id" |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
728 return "@%s = %s" % (fieldname, str(value)) |
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
729 |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
730 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
|
731 '''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
|
732 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
733 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
|
734 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
|
735 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
|
736 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
737 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
|
738 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
|
739 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
|
740 ''' |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
741 user = self.map_committer(committer) |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
742 matches = self.bzproxy.User.get({'match': [user], |
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
743 'token': self.bztoken}) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
744 if not matches['users']: |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
745 user = self.ui.config('bugzilla', 'user', 'bugs') |
21542
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
746 matches = self.bzproxy.User.get({'match': [user], |
d12d8d41428e
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Jim Hague <jim.hague@acm.org>
parents:
20673
diff
changeset
|
747 'token': self.bztoken}) |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
748 if not matches['users']: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
749 raise error.Abort(_("default bugzilla user %s email not found") |
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
750 % 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
|
751 user = matches['users'][0]['email'] |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
752 commands.append(self.makecommandline("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
|
753 |
16224
d52a6b542db1
bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Jim Hague <jim.hague@acm.org>
parents:
16223
diff
changeset
|
754 text = "\n".join(commands) + "\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
|
755 |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
756 _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
|
757 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
|
758 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
|
759 msg = mail.mimeencode(self.ui, text, _charsets) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
760 msg['From'] = user |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
761 msg['To'] = bzemail |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
762 msg['Subject'] = mail.headencode(self.ui, "Bug modification", _charsets) |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
763 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
|
764 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
|
765 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
766 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
|
767 cmds = [] |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
768 if 'hours' in newstate: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
769 cmds.append(self.makecommandline("work_time", newstate['hours'])) |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
770 if 'fix' in newstate: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
771 cmds.append(self.makecommandline("bug_status", self.fixstatus)) |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
772 cmds.append(self.makecommandline("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
|
773 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
|
774 |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
775 class bugzilla(object): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
776 # 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
|
777 # different schemas. |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
778 _versions = { |
13800
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
779 '2.16': bzmysql, |
c2ef8159dabe
bugzilla: localise all MySQL direct access inside access class.
Jim Hague <jim.hague@acm.org>
parents:
13799
diff
changeset
|
780 '2.18': bzmysql_2_18, |
13801
60256f7f30c1
bugzilla: add XMLRPC interface.
Jim Hague <jim.hague@acm.org>
parents:
13800
diff
changeset
|
781 '3.0': bzmysql_3_0, |
13802
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
782 'xmlrpc': bzxmlrpc, |
49b5a1aaf726
bugzilla: add modified XMLRPC mode that uses email to send bug comments.
Jim Hague <jim.hague@acm.org>
parents:
13801
diff
changeset
|
783 'xmlrpc+email': bzxmlrpcemail |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
784 } |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
785 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
786 _default_bug_re = (r'bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*' |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
787 r'(?P<ids>(?:\d+\s*(?:,?\s*(?:and)?)?\s*)+)' |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
788 r'\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
789 |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
790 _default_fix_re = (r'fix(?:es)?\s*(?:bugs?\s*)?,?\s*' |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
791 r'(?:nos?\.?|num(?:ber)?s?)?\s*' |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
792 r'(?P<ids>(?:#?\d+\s*(?:,?\s*(?:and)?)?\s*)+)' |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
793 r'\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
794 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
795 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
|
796 self.ui = ui |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
797 self.repo = repo |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
798 |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
799 bzversion = self.ui.config('bugzilla', 'version') |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
800 try: |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
801 bzclass = bugzilla._versions[bzversion] |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
802 except KeyError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
803 raise error.Abort(_('bugzilla version %s not supported') % |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
804 bzversion) |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
805 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
|
806 |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
807 self.bug_re = re.compile( |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
808 self.ui.config('bugzilla', 'regexp', |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
809 bugzilla._default_bug_re), re.IGNORECASE) |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
810 self.fix_re = re.compile( |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
811 self.ui.config('bugzilla', 'fixregexp', |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
812 bugzilla._default_fix_re), re.IGNORECASE) |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
813 self.split_re = re.compile(r'\D+') |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
814 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
815 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
|
816 '''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
|
817 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
818 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
|
819 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
|
820 the given changeset in their comments. |
d04fc5582772
bugzilla: keep bug IDs in set.
Jim Hague <jim.hague@acm.org>
parents:
13798
diff
changeset
|
821 ''' |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
822 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
|
823 hours = 0.0 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
824 bugs = {} |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
825 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
|
826 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
|
827 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
|
828 bugattribs = {} |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
829 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
|
830 break |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
831 if not bugmatch: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
832 m = fixmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
833 elif not fixmatch: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
834 m = bugmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
835 else: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
836 if bugmatch.start() < fixmatch.start(): |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
837 m = bugmatch |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
838 else: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
839 m = fixmatch |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
840 start = m.end() |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
841 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
|
842 bugmatch = self.bug_re.search(ctx.description(), start) |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
843 if 'fix' in bugattribs: |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
844 del bugattribs['fix'] |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
845 else: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
846 fixmatch = self.fix_re.search(ctx.description(), start) |
16223
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
847 bugattribs['fix'] = None |
ac4fd3238ead
bugzilla: allow change comment to mark bugs fixed
Jim Hague <jim.hague@acm.org>
parents:
16222
diff
changeset
|
848 |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
849 try: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
850 ids = m.group('ids') |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
851 except IndexError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
852 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
|
853 try: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
854 hours = float(m.group('hours')) |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
855 bugattribs['hours'] = hours |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
856 except IndexError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
857 pass |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
858 except TypeError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
859 pass |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
860 except ValueError: |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
861 self.ui.status(_("%s: invalid hours\n") % m.group('hours')) |
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
862 |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
863 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
|
864 if not id: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
865 continue |
16222
d7b7b453c035
bugzilla: extract optional hours from commit message and update bug time
Jim Hague <jim.hague@acm.org>
parents:
16221
diff
changeset
|
866 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
|
867 if bugs: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
868 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
|
869 if bugs: |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
870 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
|
871 return bugs |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
872 |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
873 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
|
874 '''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
|
875 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
876 def webroot(root): |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
877 '''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
|
878 url-safe path.''' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
879 count = int(self.ui.config('bugzilla', 'strip', 0)) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
880 root = util.pconvert(root) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
881 while count > 0: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
882 c = root.find('/') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
883 if c == -1: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
884 break |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
885 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
|
886 count -= 1 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
887 return root |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
888 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
889 mapfile = self.ui.config('bugzilla', 'style') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
890 tmpl = self.ui.config('bugzilla', 'template') |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
891 if not mapfile and not tmpl: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
892 tmpl = _('changeset {node|short} in repo {root} refers ' |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
893 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') |
20667
e96e9f805c19
changeset_templater: remove use_template method
Matt Mackall <mpm@selenic.com>
parents:
17537
diff
changeset
|
894 t = cmdutil.changeset_templater(self.ui, self.repo, |
e96e9f805c19
changeset_templater: remove use_template method
Matt Mackall <mpm@selenic.com>
parents:
17537
diff
changeset
|
895 False, None, tmpl, mapfile, False) |
3741
0897bf8d54c7
update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
896 self.ui.pushbuffer() |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7280
diff
changeset
|
897 t.show(ctx, changes=ctx.changeset(), |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
898 bug=str(bugid), |
2197
5de8b44f0446
define standard name for base url to use when printing hgweb urls.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2192
diff
changeset
|
899 hgweb=self.ui.config('web', 'baseurl'), |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
900 root=self.repo.root, |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
901 webroot=webroot(self.repo.root)) |
3741
0897bf8d54c7
update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
902 data = self.ui.popbuffer() |
21855
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
903 self.bzdriver.updatebug(bugid, newstate, data, util.email(ctx.user())) |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
904 |
1eda3e556845
bugzilla: stop trying to cache setup across hook invocation
Jim Hague <jim.hague@acm.org>
parents:
21842
diff
changeset
|
905 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
|
906 '''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
|
907 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
|
908 |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
909 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
|
910 '''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
|
911 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
|
912 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
|
913 if node is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
914 raise error.Abort(_('hook type %s does not pass a changeset id') % |
2192
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
915 hooktype) |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
916 try: |
2be3ac7abc21
add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
917 bz = bugzilla(ui, repo) |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6548
diff
changeset
|
918 ctx = repo[node] |
16221
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
919 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
|
920 if bugs: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
921 for bug in bugs: |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
922 bz.update(bug, bugs[bug], ctx) |
4fc9fcd991c1
bugzilla: modify access interface to include new bug states
Jim Hague <jim.hague@acm.org>
parents:
16193
diff
changeset
|
923 bz.notify(bugs, util.email(ctx.user())) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25186
diff
changeset
|
924 except Exception as e: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25660
diff
changeset
|
925 raise error.Abort(_('Bugzilla error: %s') % e) |