Ticket #1462: bugzilla2trac.py.5.diff
| File bugzilla2trac.py.5.diff, 3.6 KB (added by eburghar@…, 3 years ago) |
|---|
-
.py
old new 26 26 # 27 27 # If you run this script on a version not listed here and it is successful, 28 28 # please report it to the Trac mailing list so we can update the list. 29 BZ_VERSION = '2.1 6.5'29 BZ_VERSION = '2.18.1' 30 30 31 31 # MySQL connection parameters for the Bugzilla database. These can also 32 32 # be specified on the command line. … … 138 138 self._db = self.env.get_db_cnx() 139 139 self._db.autocommit = False 140 140 self.loginNameCache = {} 141 self.componentNameCache = {} 142 self.productNameCache = {} 141 143 self.fieldNameCache = {} 142 144 143 145 def db(self): … … 283 285 284 286 return self.loginNameCache[userid] 285 287 288 def getComponentName(self, cursor, componentid): 289 if componentid not in self.componentNameCache: 290 cursor.execute("SELECT * FROM components WHERE id = %s" % componentid) 291 componentName = cursor.fetchall() 292 293 if componentName: 294 componentName = componentName[0]['name'] 295 else: 296 print 'warning: unknown bugzilla component id %d, recording as unknown' % componentid 297 componentName = 'unknown' 298 299 self.componentNameCache[componentid] = componentName 300 301 return self.componentNameCache[componentid] 302 303 def getProductName(self, cursor, productid): 304 if productid not in self.productNameCache: 305 cursor.execute("SELECT * FROM products WHERE id = %s" % productid) 306 productName = cursor.fetchall() 307 308 if productName: 309 productName = productName[0]['name'] 310 else: 311 print 'warning: unknown bugzilla product id %d, recording as unknown' % productid 312 productName = 'unknown' 313 314 self.productNameCache[productid] = productName 315 316 return self.productNameCache[productid] 317 286 318 def getFieldName(self, cursor, fieldid): 287 319 if fieldid not in self.fieldNameCache: 288 320 cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid) … … 350 382 351 383 print 352 384 print "2. import components..." 353 sql = "SELECT value, initialowner AS owner FROM components"385 sql = "SELECT name, initialowner AS owner FROM components" 354 386 if PRODUCTS: 355 387 sql += " WHERE %s" % productFilter('program', PRODUCTS) 356 388 mysql_cur.execute(sql) 357 389 components = mysql_cur.fetchall() 358 390 for component in components: 359 391 component['owner'] = trac.getLoginName(mysql_cur, component['owner']) 360 trac.setComponentList(components, ' value')392 trac.setComponentList(components, 'name') 361 393 362 394 print 363 395 print "3. import priorities..." … … 401 433 ticket['id'] = bugid 402 434 ticket['time'] = bug['creation_ts'] 403 435 ticket['changetime'] = bug['delta_ts'] 404 ticket['component'] = bug['component']436 ticket['component'] = trac.getComponentName(mysql_cur, bug['component_id']) 405 437 ticket['severity'] = bug['bug_severity'] 406 438 ticket['priority'] = bug['priority'] 407 439 … … 574 606 if kw not in keywords: 575 607 keywords.append(kw) 576 608 577 if bug['product'] in PRODUCT_KEYWORDS: 578 kw = PRODUCT_KEYWORDS[bug['product']] 609 productName = trac.getProductName(mysql_cur, bug['product_id']) 610 if productName in PRODUCT_KEYWORDS: 611 kw = PRODUCT_KEYWORDS[productName] 579 612 # may have already been added during activity import 580 613 if kw not in keywords: 581 614 keywords.append(kw)
