##// END OF EJS Templates
Add support for Bugzilla 3.0 series to bugzilla hook....
Jim Hague -
r7019:6b1ece89 default
parent child Browse files
Show More
@@ -80,11 +80,7 b' class bugzilla_2_16(object):'
80 self.conn = MySQLdb.connect(host=host, user=user, passwd=passwd,
80 self.conn = MySQLdb.connect(host=host, user=user, passwd=passwd,
81 db=db, connect_timeout=timeout)
81 db=db, connect_timeout=timeout)
82 self.cursor = self.conn.cursor()
82 self.cursor = self.conn.cursor()
83 self.run('select fieldid from fielddefs where name = "longdesc"')
83 self.longdesc_id = self.get_longdesc_id()
84 ids = self.cursor.fetchall()
85 if len(ids) != 1:
86 raise util.Abort(_('unknown database schema'))
87 self.longdesc_id = ids[0][0]
88 self.user_ids = {}
84 self.user_ids = {}
89
85
90 def run(self, *args, **kwargs):
86 def run(self, *args, **kwargs):
@@ -96,6 +92,14 b' class bugzilla_2_16(object):'
96 self.ui.note(_('failed query: %s %s\n') % (args, kwargs))
92 self.ui.note(_('failed query: %s %s\n') % (args, kwargs))
97 raise
93 raise
98
94
95 def get_longdesc_id(self):
96 '''get identity of longdesc field'''
97 self.run('select fieldid from fielddefs where name = "longdesc"')
98 ids = self.cursor.fetchall()
99 if len(ids) != 1:
100 raise util.Abort(_('unknown database schema'))
101 return ids[0][0]
102
99 def filter_real_bug_ids(self, ids):
103 def filter_real_bug_ids(self, ids):
100 '''filter not-existing bug ids from list.'''
104 '''filter not-existing bug ids from list.'''
101 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
105 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
@@ -182,11 +186,26 b' class bugzilla_2_16(object):'
182 values (%s, %s, %s, %s)''',
186 values (%s, %s, %s, %s)''',
183 (bugid, userid, now, self.longdesc_id))
187 (bugid, userid, now, self.longdesc_id))
184
188
189 class bugzilla_3_0(bugzilla_2_16):
190 '''support for bugzilla 3.0 series.'''
191
192 def __init__(self, ui):
193 bugzilla_2_16.__init__(self, ui)
194
195 def get_longdesc_id(self):
196 '''get identity of longdesc field'''
197 self.run('select id from fielddefs where name = "longdesc"')
198 ids = self.cursor.fetchall()
199 if len(ids) != 1:
200 raise util.Abort(_('unknown database schema'))
201 return ids[0][0]
202
185 class bugzilla(object):
203 class bugzilla(object):
186 # supported versions of bugzilla. different versions have
204 # supported versions of bugzilla. different versions have
187 # different schemas.
205 # different schemas.
188 _versions = {
206 _versions = {
189 '2.16': bugzilla_2_16,
207 '2.16': bugzilla_2_16,
208 '3.0': bugzilla_3_0
190 }
209 }
191
210
192 _default_bug_re = (r'bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*'
211 _default_bug_re = (r'bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*'
General Comments 0
You need to be logged in to leave comments. Login now