Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 16 years ago

#1972 closed enhancement (duplicate)

bugzilla2trac.py

Reported by: eburghar@… Owned by: daniel
Priority: normal Milestone:
Component: admin/console Version: 0.8.4
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Here is a quick (and dirty) diff for importing bugs from bugzilla 2.18.1

--- bugzilla2trac_old.py        2005-08-26 13:52:44.000000000 +0200
+++ bugzilla2trac.py    2005-08-26 13:48:18.000000000 +0200
@@ -26,7 +26,7 @@
 #
 # If you run this script on a version not listed here and it is successful,
 # please report it to the Trac mailing list so we can update the list.
-BZ_VERSION = '2.16.5'
+BZ_VERSION = '2.18.1'

 # MySQL connection parameters for the Bugzilla database.  These can also
 # be specified on the command line.
@@ -138,6 +138,8 @@
         self._db = self.env.get_db_cnx()
         self._db.autocommit = False
         self.loginNameCache = {}
+        self.componentNameCache = {}
+        self.productNameCache = {}
         self.fieldNameCache = {}

     def db(self):
@@ -283,6 +285,36 @@

         return self.loginNameCache[userid]

+    def getComponentName(self, cursor, componentid):
+        if componentid not in self.componentNameCache:
+            cursor.execute("SELECT * FROM components WHERE id = %s" % componentid)
+            componentName = cursor.fetchall()
+
+            if componentName:
+                componentName = componentName[0]['name']
+            else:
+                print 'warning: unknown bugzilla component id %d, recording as unknown' % componentid
+                componentName = 'unknown'
+
+            self.componentNameCache[componentid] = componentName
+
+        return self.componentNameCache[componentid]
+
+    def getProductName(self, cursor, productid):
+        if productid not in self.productNameCache:
+            cursor.execute("SELECT * FROM products WHERE id = %s" % productid)
+            productName = cursor.fetchall()
+
+            if productName:
+                productName = productName[0]['name']
+            else:
+                print 'warning: unknown bugzilla product id %d, recording as unknown' % productid
+                productName = 'unknown'
+
+            self.productNameCache[productid] = productName
+
+        return self.productNameCache[productid]
+
     def getFieldName(self, cursor, fieldid):
         if fieldid not in self.fieldNameCache:
             cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid)
@@ -350,14 +382,14 @@

     print
     print "2. import components..."
-    sql = "SELECT value, initialowner AS owner FROM components"
+    sql = "SELECT name, initialowner AS owner FROM components"
     if PRODUCTS:
        sql += " WHERE %s" % productFilter('program', PRODUCTS)
     mysql_cur.execute(sql)
     components = mysql_cur.fetchall()
     for component in components:
                component['owner'] = trac.getLoginName(mysql_cur, component['owner'])
-    trac.setComponentList(components, 'value')
+    trac.setComponentList(components, 'name')

     print
     print "3. import priorities..."
@@ -401,7 +433,7 @@
         ticket['id'] = bugid
         ticket['time'] = bug['creation_ts']
         ticket['changetime'] = bug['delta_ts']
-        ticket['component'] = bug['component']
+        ticket['component'] = trac.getComponentName(mysql_cur, bug['component_id'])
         ticket['severity'] = bug['bug_severity']
         ticket['priority'] = bug['priority']

@@ -574,8 +606,9 @@
             if kw not in keywords:
                 keywords.append(kw)

-        if bug['product'] in PRODUCT_KEYWORDS:
-            kw = PRODUCT_KEYWORDS[bug['product']]
+        productName = trac.getProductName(mysql_cur, bug['product_id'])
+        if productName in PRODUCT_KEYWORDS:
+            kw = PRODUCT_KEYWORDS[productName]
             # may have already been added during activity import
             if kw not in keywords:
                 keywords.append(kw)

Attachments (0)

Change History (1)

comment:1 by Christopher Lenz, 17 years ago

Resolution: duplicate
Status: newclosed

There are various pending improvements to the Bugzilla import script in #1462. Please test the patches attached there.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain daniel.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from daniel to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.