author | Dario Sestito <darios@symbian.org> |
Tue, 09 Mar 2010 12:36:24 +0000 | |
changeset 187 | dbf40764ca6a |
parent 41 | ac3a70c9f81c |
permissions | -rw-r--r-- |
41 | 1 |
# |
2 |
# Copyright (c) 2009 Symbian Foundation. |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Symbian Foundation - Initial contribution |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# {Name/Company} - {Description of contribution} |
|
14 |
# |
|
15 |
# Description: |
|
16 |
# Mercurial hook to turn hg tags into package versions in Bugzilla |
|
17 |
# |
|
18 |
||
21
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
19 |
'''Bugzilla integration for adding versions from tags |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
20 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
21 |
The hook updates the Bugzilla database directly. Only Bugzilla installations |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
22 |
using MySQL are supported. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
23 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
24 |
This hook uses the same .hgrc parameters as the default Bugzilla hook. There |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
25 |
is no need for configuring the same stuff twice. (connection, etc.) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
26 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
27 |
Configuring the extension: (same as Bugzilla -hook) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
28 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
29 |
[bugzilla] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
30 |
host Hostname of the MySQL server holding the Bugzilla database. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
31 |
db Name of the Bugzilla database in MySQL. Default 'bugs'. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
32 |
user Username to use to access MySQL server. Default 'bugs'. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
33 |
password Password to use to access MySQL server. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
34 |
timeout Database connection timeout (seconds). Default 5. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
35 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
36 |
Additional elements under Bugzilla -section: (new items) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
37 |
[bugzilla] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
38 |
product The name on the Bugzilla product that is used for adding |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
39 |
the new versions. |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
40 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
41 |
Activating the extension: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
42 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
43 |
[extensions] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
44 |
hgext.versiontobugzilla = |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
45 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
46 |
[hooks] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
47 |
incoming.versiontobugzilla = python:hgext.versiontobugzilla.hook |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
48 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
49 |
Example configuration in hgrc: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
50 |
[bugzilla] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
51 |
host = localhost |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
52 |
user = bugs |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
53 |
password = password |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
54 |
product = my_product |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
55 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
56 |
[extensions] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
57 |
hgext.versiontobugzilla = |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
58 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
59 |
[hooks] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
60 |
incoming.versiontobugzilla = python:hgext.versiontobugzilla.hook |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
61 |
''' |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
62 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
63 |
from mercurial import util |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
64 |
import re |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
65 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
66 |
MySQLdb = None |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
67 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
68 |
class BugzillaClient: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
69 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
70 |
def __init__(self, ui, repo, node): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
71 |
self.tag = None |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
72 |
self.ui = ui |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
73 |
self.repo = repo |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
74 |
self.node = node |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
75 |
self.product = ui.config('bugzilla', 'product') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
76 |
self.host = ui.config('bugzilla', 'host', 'localhost') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
77 |
self.user = ui.config('bugzilla', 'user', 'bugs') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
78 |
self.passwd = ui.config('bugzilla', 'password') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
79 |
self.db = ui.config('bugzilla', 'db', 'bugs') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
80 |
self.timeout = int(ui.config('bugzilla', 'timeout', 10)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
81 |
self.connection = MySQLdb.connect(host=self.host, user=self.user, passwd=self.passwd, |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
82 |
db=self.db, connect_timeout=self.timeout) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
83 |
self.cursor = self.connection.cursor() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
84 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
85 |
def printMessageInVerboseMode(self, message): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
86 |
'''Prints a message to console if hg has been executed with -v option.''' |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
87 |
self.ui.note(message) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
88 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
89 |
def executeDatabaseQuery(self, *args, **kwargs): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
90 |
self.printMessageInVerboseMode('Bugzilla: query: %s %s\n' % (args, kwargs)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
91 |
try: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
92 |
self.cursor.execute(*args, **kwargs) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
93 |
except MySQLdb.MySQLError: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
94 |
self.printMessageInVerboseMode('Bugzilla: failed query: %s %s\n' % (args, kwargs)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
95 |
raise |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
96 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
97 |
def commitContainsTag(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
98 |
self.parseTagFromCommitMessage() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
99 |
if self.tag: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
100 |
return True |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
101 |
else: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
102 |
return False |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
103 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
104 |
def parseTagFromCommitMessage(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
105 |
ctx = self.repo[self.node] |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
106 |
version_re = re.compile(('Added tag (.+) for changeset [0-9a-h]+'), re.IGNORECASE) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
107 |
m = version_re.search(ctx.description()) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
108 |
if m: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
109 |
self.tag = m.group(1) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
110 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
111 |
def insertTagIntoDatabase(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
112 |
self.makeSureThatProductExists() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
113 |
if not self.doesVersionAlreadyExist(): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
114 |
self.printMessageInVerboseMode("Bugzilla: adding version '%s' to product '%s' in database.\n" % (self.tag, self.product)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
115 |
self.insertNewVersionIntoDatabase() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
116 |
else: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
117 |
self.printMessageInVerboseMode("Bugzilla: product '%s' already has a version '%s' in database. Not trying to add it again." % (self.product, self.tag)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
118 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
119 |
def makeSureThatProductExists(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
120 |
self.executeDatabaseQuery('select id from products where name = %s', (self.product,)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
121 |
ids = self.cursor.fetchall() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
122 |
if len(ids) != 1: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
123 |
raise util.Abort("Product '%s' does not exist in database, please check the [bugzilla] -section in hgrc." % self.product) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
124 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
125 |
def doesVersionAlreadyExist(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
126 |
self.executeDatabaseQuery('select * from versions where value = %s and product_id in (select id from products where name=%s )', (self.tag, self.product)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
127 |
ids = self.cursor.fetchall() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
128 |
if len(ids) == 1: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
129 |
return True |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
130 |
else: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
131 |
return False |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
132 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
133 |
def insertNewVersionIntoDatabase(self): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
134 |
self.executeDatabaseQuery('insert into versions (value, product_id) values (%s, (select id from products where name=%s ))', (self.tag, self.product)) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
135 |
self.connection.commit() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
136 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
137 |
def hook(ui, repo, hooktype, node=None, **kwargs): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
138 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
139 |
try: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
140 |
import MySQLdb as mysql |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
141 |
global MySQLdb |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
142 |
MySQLdb = mysql |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
143 |
except ImportError, err: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
144 |
raise util.Abort('MySQL driver not installed: %s' % err) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
145 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
146 |
if node is None: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
147 |
raise util.Abort('Only hooks that have changesetid''s can be used.') |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
148 |
|
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
149 |
try: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
150 |
bzClient = BugzillaClient(ui, repo, node) |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
151 |
if bzClient.commitContainsTag(): |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
152 |
bzClient.insertTagIntoDatabase() |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
153 |
except MySQLdb.MySQLError, err: |
f55ca49f7f44
Added initial versions of filecheck and hg tags to bugzilla version hooks
tahirm@symbian.org
parents:
diff
changeset
|
154 |
raise util.Abort('Database error: %s' % err[1]) |