* cvs-hg-db-blame.py expects a path to cvs-mirror default tip
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 05 Dec 2008 15:21:34 -0500
changeset 2 5711fbbdbe06
parent 1 4d8dca37715d
push id1
push userbsmedberg@mozilla.com
push dateFri, 05 Dec 2008 21:22:54 +0000
* cvs-hg-db-blame.py expects a path to cvs-mirror * take the absolute path of __file__ in python before using dirname * create the database structure we are actually using
Makefile
cvs-hg-db-blame.py
cvs-hg-db.py
--- a/Makefile
+++ b/Makefile
@@ -9,9 +9,9 @@ rsync:
 
 pull:
 	rm -rf mozilla
 	cvs -d $(CURDIR)/cvs-mirror co -r $(IMPORTREV) mozilla
 
 createdb:
 	rm -f $(DBFILE)
 	python cvs-hg-db.py mozilla $(DBFILE)
-	python cvs-hg-db-blame.py mozilla $(DBFILE)
+	python cvs-hg-db-blame.py cvs-mirror/mozilla $(DBFILE)
--- a/cvs-hg-db-blame.py
+++ b/cvs-hg-db-blame.py
@@ -1,14 +1,14 @@
 import sqlite3 as sqlite
 import sys
 import os
 import os.path
 
-thisdir = os.path.dirname(__file__)
+thisdir = os.path.dirname(os.path.realpath(__file__))
 
 def getblame(id, file, targetrev):
     lastrev = None
     for line in os.popen("perl %s/cvsblame.pl '%s,v' %s" % (thisdir, file, targetrev),'r'):
         (num, who, rev) = line.split(',')
         num = int(num)
         rev = rev.rstrip()
         if rev != lastrev:
--- a/cvs-hg-db.py
+++ b/cvs-hg-db.py
@@ -1,16 +1,18 @@
 import sqlite3 as sqlite
 import sys
 import os
 import os.path
 
 def createfiledb(conn):
-    conn.execute("CREATE TABLE files (file text, rev text)")
+    conn.execute("CREATE TABLE files (id INTEGER PRIMARY KEY AUTOINCREMENT, file text, rev text)")
     conn.execute("CREATE INDEX files_files ON files (file)")
+    conn.execute("CREATE TABLE blame (fileid INTEGER, rev TEXT, who TEXT, minline INTEGER, maxline INTEGER)")
+    conn.execute("CREATE INDEX blame_fileid ON blame (fileid, minline)")
     conn.commit()
 
 def GetCVSRevision(file):
     (path, filename) = os.path.split(file)
     entries = os.path.join(path, "CVS", "Entries")
     if not os.path.isfile(entries):
         return None
     f = open(entries, "r")