Re: [SRM] Bug at conversion scripts of sourceforge to trac (trac)
I've added the package diff for review.
diff --git a/debian/changelog b/debian/changelog
index 19fe1b4..40aeafe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+trac (0.10.3-1etch3) stable; urgency=low
+
+ * Fix contrib/sourceforge2trac to work with Trac 0.10.3. Closes:
+ #444052
+ * Fix redirection to https after posting. Closes: #438685
+
+ -- Otavio Salvador <otavio@ossystems.com.br> Wed, 21 May 2008 13:42:59 -0300
+
trac (0.10.3-1etch2) stable; urgency=low
* Add 03_backport_r4664_r4670_r4699.dpatch patch backporting fixes from
@@ -347,5 +355,3 @@ trac (0.7.1-1) unstable; urgency=low
* Man pages taken from trunk.
-- Jesus Climent <jesus.climent@hispalinux.es> Mon, 19 Jul 2004 12:01:17 +0000
-
-
diff --git a/debian/patches/04_https_post_redirect.patch b/debian/patches/04_https_post_redirect.patch
new file mode 100644
index 0000000..dbd184e
--- /dev/null
+++ b/debian/patches/04_https_post_redirect.patch
@@ -0,0 +1,20 @@
+diff -Nur -x '*.orig' -x '*~' trac/trac/web/api.py trac.new/trac/web/api.py
+--- trac/trac/web/api.py 2008-05-21 13:27:39.000000000 -0300
++++ trac.new/trac/web/api.py 2008-05-21 13:34:39.000000000 -0300
+@@ -325,10 +325,12 @@
+
+ self.send_response(status)
+ if not url.startswith('http://') and not url.startswith('https://'):
+- # Make sure the URL is absolute
+- url = urlparse.urlunparse((self.scheme,
+- urlparse.urlparse(self.base_url)[1],
+- url, None, None, None))
++ # Make sure the URL is absolute, honor base_url for
++ # scheme and host if present
++ scheme, host, path, params, query, fragment = urlparse.urlparse(
++ self.abs_href())
++ url = urlparse.urlunparse((scheme, host, url, None, None, None))
++
+ self.send_header('Location', url)
+ self.send_header('Content-Type', 'text/plain')
+ self.send_header('Pragma', 'no-cache')
diff --git a/debian/patches/05_fix_sourceforge2trac.patch b/debian/patches/05_fix_sourceforge2trac.patch
new file mode 100644
index 0000000..93407fa
--- /dev/null
+++ b/debian/patches/05_fix_sourceforge2trac.patch
@@ -0,0 +1,114 @@
+diff -Nur -x '*.orig' -x '*~' trac/contrib/sourceforge2trac.py trac.new/contrib/sourceforge2trac.py
+--- trac/contrib/sourceforge2trac.py 2008-04-24 05:41:38.000000000 -0300
++++ trac.new/contrib/sourceforge2trac.py 2008-05-21 13:40:21.000000000 -0300
+@@ -19,7 +19,7 @@
+ def __init__(self, e):
+ for field in e:
+ if field.get('name').endswith('date'):
+- setattr(self, field.get('name'), datetime.fromtimestamp(int(field.text)))
++ setattr(self, field.get('name'), field.text)
+ else:
+ setattr(self, field.get('name'), field.text)
+
+@@ -133,12 +133,10 @@
+ raise Exception("Will not modify database with existing tickets!")
+
+ c = self.db().cursor()
+- c.execute("""DELETE FROM enum WHERE kind='ticket_type'""")
++ c.execute("""DELETE FROM enum WHERE type='ticket_type'""")
+ for i, value in enumerate(s):
+- c.execute("""INSERT INTO enum (kind, name, value) VALUES (%s, %s, %s)""",
+- "ticket_type",
+- value,
+- i)
++ c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""",
++ ("ticket_type", value, i))
+ self.db().commit()
+
+ def setPriorityList(self, s):
+@@ -147,12 +145,10 @@
+ raise Exception("Will not modify database with existing tickets!")
+
+ c = self.db().cursor()
+- c.execute("""DELETE FROM enum WHERE kind='priority'""")
++ c.execute("""DELETE FROM enum WHERE type='priority'""")
+ for i, value in enumerate(s):
+- c.execute("""INSERT INTO enum (kind, name, value) VALUES (%s, %s, %s)""",
+- "priority",
+- value,
+- i)
++ c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""",
++ ("priority", value, i))
+ self.db().commit()
+
+
+@@ -165,7 +161,7 @@
+ c.execute("""DELETE FROM component""")
+ for value in l:
+ c.execute("""INSERT INTO component (name) VALUES (%s)""",
+- value)
++ (value, ))
+ self.db().commit()
+
+ def setVersionList(self, v):
+@@ -177,7 +173,7 @@
+ c.execute("""DELETE FROM version""")
+ for value in v:
+ c.execute("""INSERT INTO version (name) VALUES (%s)""",
+- value)
++ (value, ))
+ self.db().commit()
+
+ def setMilestoneList(self, m):
+@@ -189,7 +185,7 @@
+ c.execute("""DELETE FROM milestone""")
+ for value in m:
+ c.execute("""INSERT INTO milestone (name) VALUES (%s)""",
+- value)
++ (value, ))
+ self.db().commit()
+
+ def addTicket(self, type, time, changetime, component,
+@@ -202,6 +198,8 @@
+ status = 'assigned'
+ else:
+ status = 'new'
++ if len(changetime) == 0:
++ changetime = 0
+
+ c.execute("""INSERT INTO ticket (type, time, changetime, component,
+ priority, owner, reporter, cc,
+@@ -211,25 +209,28 @@
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s,
+ %s, %s, %s)""",
+- type, time, changetime, component,
++ (type, time, changetime, component,
+ priority, owner, reporter, cc,
+ version, milestone, status.lower(), resolution,
+- summary, '{{{\n%s\n}}}' % (description, ), keywords)
++ summary, '{{{\n%s\n}}}' % (description, ), keywords))
+ self.db().commit()
+- return self.db().db.sqlite_last_insert_rowid()
++ return self.db().get_last_id(c, "ticket")
+
+ def addTicketComment(self, ticket, time, author, value):
+ c = self.db().cursor()
++ # uncomment this if you're hitting conflicts, I don't have the time to
++ # make this automatically fix things.
++ #print "Ticket=", ticket, ", time=", time, ", author=", author
+ c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue)
+ VALUES (%s, %s, %s, %s, %s, %s)""",
+- ticket, time.strftime('%s'), author, 'comment', '', '{{{\n%s\n}}}' % (value, ))
++ (ticket, time, author, 'comment', '', '{{{\n%s\n}}}' % (value, )))
+ self.db().commit()
+
+ def addTicketChange(self, ticket, time, author, field, oldvalue, newvalue):
+ c = self.db().cursor()
+ c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue)
+ VALUES (%s, %s, %s, %s, %s, %s)""",
+- ticket, time.strftime('%s'), author, field, oldvalue, newvalue)
++ (ticket, time, author, field, oldvalue, newvalue))
+ self.db().commit()
+
+
--
O T A V I O S A L V A D O R
---------------------------------------------
E-mail: otavio@debian.org UIN: 5906116
GNU/Linux User: 239058 GPG ID: 49A5F855
Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
you the whole house."
Reply to: