annotate hgext/bugzilla.py @ 7588:489c2cfbdd71

convert/gnuarch: correct indentation
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sun, 04 Jan 2009 19:12:42 +0100
parents d8cd79fbed3c
children 6c89dd0a7797
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
4 #
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
6 # of the GNU General Public License, incorporated herein by reference.
7504
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
7
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
8 '''Bugzilla integration
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
9
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
10 This hook extension adds comments on bugs in Bugzilla when changesets
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
11 that refer to bugs by Bugzilla ID are seen. The hook does not change bug
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
12 status.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
13
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
14 The hook updates the Bugzilla database directly. Only Bugzilla installations
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
15 using MySQL are supported.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
16
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
17 The hook relies on a Bugzilla script to send bug change notification emails.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
18 That script changes between Bugzilla versions; the 'processmail' script used
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
19 prior to 2.18 is replaced in 2.18 and subsequent versions by
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
20 'config/sendbugmail.pl'. Note that these will be run by Mercurial as the user
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
21 pushing the change; you will need to ensure the Bugzilla install file
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
22 permissions are set appropriately.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
23
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
24 Configuring the extension:
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
25
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
26 [bugzilla]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
27 host Hostname of the MySQL server holding the Bugzilla database.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
28 db Name of the Bugzilla database in MySQL. Default 'bugs'.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
29 user Username to use to access MySQL server. Default 'bugs'.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
30 password Password to use to access MySQL server.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
31 timeout Database connection timeout (seconds). Default 5.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
32 version Bugzilla version. Specify '3.0' for Bugzilla versions from
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
33 3.0 onwards, and '2.16' for versions prior to 3.0.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
34 bzuser Fallback Bugzilla user name to record comments with, if
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
35 changeset committer cannot be found as a Bugzilla user.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
36 notify The command to run to get Bugzilla to send bug change
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
37 notification emails. Substitutes one string parameter,
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
38 the bug ID. Default 'cd /var/www/html/bugzilla && '
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
39 './processmail %s nobody@nowhere.com'.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
40 regexp Regular expression to match bug IDs in changeset commit message.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
41 Must contain one "()" group. The default expression matches
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
42 'Bug 1234', 'Bug no. 1234', 'Bug number 1234',
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
43 'Bugs 1234,5678', 'Bug 1234 and 5678' and variations thereof.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
44 Matching is case insensitive.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
45 style The style file to use when formatting comments.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
46 template Template to use when formatting comments. Overrides
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
47 style if specified. In addition to the usual Mercurial
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
48 keywords, the extension specifies:
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
49 {bug} The Bugzilla bug ID.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
50 {root} The full pathname of the Mercurial repository.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
51 {webroot} Stripped pathname of the Mercurial repository.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
52 {hgweb} Base URL for browsing Mercurial repositories.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
53 Default 'changeset {node|short} in repo {root} refers '
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
54 'to bug {bug}.\\ndetails:\\n\\t{desc|tabindent}'
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
55 strip The number of slashes to strip from the front of {root}
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
56 to produce {webroot}. Default 0.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
57 usermap Path of file containing Mercurial committer ID to Bugzilla user
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
58 ID mappings. If specified, the file should contain one mapping
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
59 per line, "committer"="Bugzilla user". See also the
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
60 [usermap] section.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
61
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
62 [usermap]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
63 Any entries in this section specify mappings of Mercurial committer ID
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
64 to Bugzilla user ID. See also [bugzilla].usermap.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
65 "committer"="Bugzilla user"
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
66
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
67 [web]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
68 baseurl Base URL for browsing Mercurial repositories. Reference from
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
69 templates as {hgweb}.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
70
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
71 Activating the extension:
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
72
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
73 [extensions]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
74 hgext.bugzilla =
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
75
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
76 [hooks]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
77 # 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
78 incoming.bugzilla = python:hgext.bugzilla.hook
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
79
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
80 Example configuration:
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
81
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
82 This example configuration is for a collection of Mercurial repositories
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
83 in /var/local/hg/repos/ used with a local Bugzilla 3.2 installation in
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
84 /opt/bugzilla-3.2.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
85
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
86 [bugzilla]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
87 host=localhost
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
88 password=XYZZY
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
89 version=3.0
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
90 bzuser=unknown@domain.com
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
91 notify=cd /opt/bugzilla-3.2 && perl -T contrib/sendbugmail.pl %%s bugmail@domain.com
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
92 template=Changeset {node|short} in {root|basename}.\\n{hgweb}/{webroot}/rev/{node|short}\\n\\n{desc}\\n
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
93 strip=5
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
94
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
95 [web]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
96 baseurl=http://dev.domain.com/hg
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
97
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
98 [usermap]
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
99 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
100
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
101 Commits add a comment to the Bugzilla bug record of the form:
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
102
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
103 Changeset 3b16791d6642 in repository-name.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
104 http://dev.domain.com/hg/repository-name/rev/3b16791d6642
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
105
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
106 Changeset commit comment. Bug 1234.
d8cd79fbed3c Revise Bugzilla module comments into extension help.
Jim Hague <jim.hague@acm.org>
parents: 7493
diff changeset
107 '''
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
108
3891
6b4127c7d52a Simplify i18n imports
Matt Mackall <mpm@selenic.com>
parents: 3877
diff changeset
109 from mercurial.i18n import _
6211
f89fd07fc51d Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents: 5975
diff changeset
110 from mercurial.node import short
3877
abaee83ce0a6 Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents: 3876
diff changeset
111 from mercurial import cmdutil, templater, util
6548
962eb403165b replace usage of os.popen() with util.popen()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6211
diff changeset
112 import re, time
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
113
2218
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
114 MySQLdb = None
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
115
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
116 def buglist(ids):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
117 return '(' + ','.join(map(str, ids)) + ')'
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
118
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
119 class bugzilla_2_16(object):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
120 '''support for bugzilla version 2.16.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
121
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
122 def __init__(self, ui):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
123 self.ui = ui
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
124 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
125 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
126 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
127 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
128 timeout = int(self.ui.config('bugzilla', 'timeout', 5))
2306
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
129 usermap = self.ui.config('bugzilla', 'usermap')
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
130 if usermap:
3435
e4452c3fa736 use ui.readsections in the bugzilla extension
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2306
diff changeset
131 self.ui.readsections(usermap, 'usermap')
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
132 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
133 (host, db, user, '*' * len(passwd)))
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
134 self.conn = MySQLdb.connect(host=host, user=user, passwd=passwd,
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
135 db=db, connect_timeout=timeout)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
136 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
137 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
138 self.user_ids = {}
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
139
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
140 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
141 '''run a query.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
142 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
143 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
144 self.cursor.execute(*args, **kwargs)
7280
810ca383da9c remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7019
diff changeset
145 except MySQLdb.MySQLError:
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
146 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
147 raise
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
148
7019
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
149 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
150 '''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
151 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
152 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
153 if len(ids) != 1:
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
154 raise util.Abort(_('unknown database schema'))
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
155 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
156
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
157 def filter_real_bug_ids(self, ids):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
158 '''filter not-existing bug ids from list.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
159 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
6762
f67d1468ac50 util: add sort helper
Matt Mackall <mpm@selenic.com>
parents: 6747
diff changeset
160 return util.sort([c[0] for c in self.cursor.fetchall()])
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
161
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
162 def filter_unknown_bug_ids(self, node, ids):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
163 '''filter bug ids from list that already refer to this changeset.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
164
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
165 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
166 bug_id in %s and thetext like "%%%s%%"''' %
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
167 (buglist(ids), short(node)))
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
168 unknown = dict.fromkeys(ids)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
169 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
170 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
171 (id, short(node)))
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
172 unknown.pop(id, None)
6762
f67d1468ac50 util: add sort helper
Matt Mackall <mpm@selenic.com>
parents: 6747
diff changeset
173 return util.sort(unknown.keys())
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
174
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
175 def notify(self, ids):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
176 '''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
177
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
178 self.ui.status(_('telling bugzilla to send mail:\n'))
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
179 for id in ids:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
180 self.ui.status(_(' bug %s\n') % id)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
181 cmd = self.ui.config('bugzilla', 'notify',
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
182 'cd /var/www/html/bugzilla && '
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
183 './processmail %s nobody@nowhere.com') % id
6548
962eb403165b replace usage of os.popen() with util.popen()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6211
diff changeset
184 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
185 out = fp.read()
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
186 ret = fp.close()
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
187 if ret:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
188 self.ui.warn(out)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
189 raise util.Abort(_('bugzilla notify command %s') %
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
190 util.explain_exit(ret)[0])
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
191 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
192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
193 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
194 '''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
195 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
196 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
197 except KeyError:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
198 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
199 userid = int(user)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
200 except ValueError:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
201 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
202 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
203 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
204 all = self.cursor.fetchall()
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
205 if len(all) != 1:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
206 raise KeyError(user)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
207 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
208 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
209 return userid
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
210
2306
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
211 def map_committer(self, user):
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
212 '''map name of committer to bugzilla user name.'''
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
213 for committer, bzuser in self.ui.configitems('usermap'):
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
214 if committer.lower() == user.lower():
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
215 return bzuser
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
216 return user
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
217
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
218 def add_comment(self, bugid, text, committer):
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
219 '''add comment to bug. try adding comment as committer of
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
220 changeset, otherwise as default bugzilla user.'''
2306
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
221 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
222 try:
2306
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
223 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
224 except KeyError:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
225 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
226 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
227 if not defaultuser:
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
228 raise util.Abort(_('cannot find bugzilla user id for %s') %
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
229 user)
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
230 userid = self.get_user_id(defaultuser)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
231 except KeyError:
2306
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
232 raise util.Abort(_('cannot find bugzilla user id for %s or %s') %
4c67ba93560b bugzilla: allow to map between committer email and bugzilla user name.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2239
diff changeset
233 (user, defaultuser))
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
234 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
235 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
236 (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
237 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
238 (bugid, userid, now, text))
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
239 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
240 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
241 (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
242 self.conn.commit()
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
243
7019
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
244 class bugzilla_3_0(bugzilla_2_16):
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
245 '''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
246
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
247 def __init__(self, ui):
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
248 bugzilla_2_16.__init__(self, ui)
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
249
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
250 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
251 '''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
252 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
253 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
254 if len(ids) != 1:
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
255 raise util.Abort(_('unknown database schema'))
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
256 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
257
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
258 class bugzilla(object):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
259 # 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
260 # different schemas.
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
261 _versions = {
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
262 '2.16': bugzilla_2_16,
7019
6b1ece890f9a Add support for Bugzilla 3.0 series to bugzilla hook.
Jim Hague <jim.hague@acm.org>
parents: 6762
diff changeset
263 '3.0': bugzilla_3_0
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
264 }
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
265
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
266 _default_bug_re = (r'bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*'
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
267 r'((?:\d+\s*(?:,?\s*(?:and)?)?\s*)+)')
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
268
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
269 _bz = None
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
270
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
271 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
272 self.ui = ui
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
273 self.repo = repo
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
274
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
275 def bz(self):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
276 '''return object that knows how to talk to bugzilla version in
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
277 use.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
278
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
279 if bugzilla._bz is None:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
280 bzversion = self.ui.config('bugzilla', 'version')
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
281 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
282 bzclass = bugzilla._versions[bzversion]
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
283 except KeyError:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
284 raise util.Abort(_('bugzilla version %s not supported') %
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
285 bzversion)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
286 bugzilla._bz = bzclass(self.ui)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
287 return bugzilla._bz
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
288
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
289 def __getattr__(self, key):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
290 return getattr(self.bz(), key)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
291
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
292 _bug_re = None
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
293 _split_re = None
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
294
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
295 def find_bug_ids(self, ctx):
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
296 '''find valid bug ids that are referred to in changeset
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
297 comments and that do not already have references to this
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
298 changeset.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
299
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
300 if bugzilla._bug_re is None:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
301 bugzilla._bug_re = re.compile(
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
302 self.ui.config('bugzilla', 'regexp', bugzilla._default_bug_re),
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
303 re.IGNORECASE)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
304 bugzilla._split_re = re.compile(r'\D+')
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
305 start = 0
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
306 ids = {}
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
307 while True:
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
308 m = bugzilla._bug_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
309 if not m:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
310 break
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
311 start = m.end()
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
312 for id in bugzilla._split_re.split(m.group(1)):
2239
5e5adc1910ed bugzilla hook: skip empty groups.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2221
diff changeset
313 if not id: continue
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
314 ids[int(id)] = 1
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
315 ids = ids.keys()
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
316 if ids:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
317 ids = self.filter_real_bug_ids(ids)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
318 if ids:
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
319 ids = self.filter_unknown_bug_ids(ctx.node(), ids)
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
320 return ids
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
321
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
322 def update(self, bugid, ctx):
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
323 '''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
324
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
325 def webroot(root):
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
326 '''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
327 url-safe path.'''
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
328 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
329 root = util.pconvert(root)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
330 while count > 0:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
331 c = root.find('/')
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
332 if c == -1:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
333 break
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
334 root = root[c+1:]
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
335 count -= 1
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
336 return root
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
337
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
338 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
339 tmpl = self.ui.config('bugzilla', 'template')
3741
0897bf8d54c7 update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents: 3643
diff changeset
340 t = cmdutil.changeset_templater(self.ui, self.repo,
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3741
diff changeset
341 False, mapfile, False)
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
342 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
343 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
344 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
345 if tmpl:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
346 tmpl = templater.parsestring(tmpl, quoted=False)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
347 t.use_template(tmpl)
3741
0897bf8d54c7 update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents: 3643
diff changeset
348 self.ui.pushbuffer()
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7280
diff changeset
349 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
350 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
351 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
352 root=self.repo.root,
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
353 webroot=webroot(self.repo.root))
3741
0897bf8d54c7 update bugzilla extension to use ui buffers
Matt Mackall <mpm@selenic.com>
parents: 3643
diff changeset
354 data = self.ui.popbuffer()
5975
75d9fe70c654 templater: move email function to util
Matt Mackall <mpm@selenic.com>
parents: 4431
diff changeset
355 self.add_comment(bugid, data, util.email(ctx.user()))
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
356
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
357 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
358 '''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
359 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
360 seen multiple times does not fill bug with duplicate data.'''
2218
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
361 try:
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
362 import MySQLdb as mysql
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
363 global MySQLdb
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
364 MySQLdb = mysql
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
365 except ImportError, err:
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
366 raise util.Abort(_('python mysql support not available: %s') % err)
afe24f5b7a9e only import mysql module if hook used.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2192
diff changeset
367
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
368 if node is None:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
369 raise util.Abort(_('hook type %s does not pass a changeset id') %
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
370 hooktype)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
371 try:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
372 bz = bugzilla(ui, repo)
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6548
diff changeset
373 ctx = repo[node]
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
374 ids = bz.find_bug_ids(ctx)
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
375 if ids:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
376 for id in ids:
3976
f8849648b0e2 bugzilla: use contexts, simplify
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3891
diff changeset
377 bz.update(id, ctx)
2192
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
378 bz.notify(ids)
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
379 except MySQLdb.MySQLError, err:
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
380 raise util.Abort(_('database error: %s') % err[1])
2be3ac7abc21 add bugzilla integration hook. example of writing hook in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
381