Minor syntax fixes... also, the scripts don't quite match the shipped schema ted gave me.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 05 Dec 2008 14:47:46 -0500
changeset 1 4d8dca37715d
parent 0 26310badc39b
child 2 5711fbbdbe06
push id1
push userbsmedberg@mozilla.com
push dateFri, 05 Dec 2008 21:22:54 +0000
Minor syntax fixes... also, the scripts don't quite match the shipped schema ted gave me.
.hgignore
Makefile
cvs-hg-db-blame.py
cvs-hg-db.py
new file mode 100644
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,3 @@
+^mozilla/
+^cvs-mirror/
+\.db$
new file mode 100644
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+IMPORTREV = HG_REPO_INITIAL_IMPORT
+DBFILE = $(IMPORTREV)-blame.db
+
+default: rsync pull createdb
+
+rsync:
+	mkdir -p cvs-mirror
+	rsync -az --delete --delay-updates cvs-mirror.mozilla.org::mozilla cvs-mirror
+
+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)
--- a/cvs-hg-db-blame.py
+++ b/cvs-hg-db-blame.py
@@ -1,34 +1,35 @@
 import sqlite3 as sqlite
 import sys
 import os
 import os.path
 
+thisdir = os.path.dirname(__file__)
+
 def getblame(id, file, targetrev):
     lastrev = None
-    for line in os.popen("/Users/luser/build/cvsblame.pl '%s,v' %s" % (file, targetrev),'r'):
+    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:
             if lastrev != None:
                 global numblame
                 numblame += 1
                 yield (id, lastrev, lastwho, minline, num - 1)
             lastrev = rev
             lastwho = who
             minline = num
     if lastrev != None:
         global numblame
         numblame += 1
         yield (id, lastrev, lastwho, minline, num)
 
-db = sys.argv[2]
-cvsdir = sys.argv[1]
+cvsdir, db = sys.argv[1:]
 
 conn = sqlite.connect(db)
 res = conn.execute("SELECT id, file, rev FROM files")
 numfiles = 0
 numblame = 0
 for (id,file,rev) in res:
     numfiles += 1
     conn.executemany("INSERT INTO blame (fileid, rev, who, minline, maxline) values(?,?,?,?,?)",
--- a/cvs-hg-db.py
+++ b/cvs-hg-db.py
@@ -15,18 +15,18 @@ def GetCVSRevision(file):
         return None
     f = open(entries, "r")
     for line in f:
         parts = line.split("/")
         if len(parts) > 1 and parts[1] == filename:
             return parts[2]
     return None
 
-db = sys.argv[2]
-mozdir = sys.argv[1]
+mozdir, db = sys.argv[1:]
+
 createdb = False
 if not os.path.exists(db):
     createdb = True
 conn = sqlite.connect(db)
 if createdb:
     createfiledb(conn)
 
 c = 0