def __init__(self, svnrepopath, sqlitedbpath, verbose=False, **kwargs): username = kwargs.pop('username', None) password = kwargs.pop('password', None) logging.info("Repo url : " + svnrepopath) self.svnclient = svnlogiter.SVNLogClient( svnrepopath, BINARYFILEXT, username=username, password=password) self.db = SVNLogDB(dbpath=sqlitedbpath) self.verbose = verbose self.commit_after_numrev = kwargs.pop('commit_after_numrev', 10) self.filediff = kwargs.pop('filediff', False) if self.commit_after_numrev < 1: self.commit_after_numrev = 1
class SVNLog2Sqlite: def __init__(self, svnrepopath, sqlitedbpath, verbose=False, **kwargs): username = kwargs.pop('username', None) password = kwargs.pop('password', None) logging.info("Repo url : " + svnrepopath) self.svnclient = svnlogiter.SVNLogClient( svnrepopath, BINARYFILEXT, username=username, password=password) self.db = SVNLogDB(dbpath=sqlitedbpath) self.verbose = verbose self.commit_after_numrev = kwargs.pop('commit_after_numrev', 10) self.filediff = kwargs.pop('filediff', False) if self.commit_after_numrev < 1: self.commit_after_numrev = 1 def convert(self, svnrevstartdate, svnrevenddate, bUpdLineCount=True, maxtrycount=3): # First check if this a full conversion or a partial conversion self.db.connect() self.CreateTables() for trycount in range(0, maxtrycount): try: laststoredrev = self.getLastStoredRev() rootUrl = self.svnclient.getRootUrl() self.printVerbose("Root url found : %s" % rootUrl) (startrevno, endrevno) = self.svnclient.findStartEndRev( svnrevstartdate, svnrevenddate) startrevno = max(startrevno, laststoredrev + 1) if startrevno <= endrevno: self.printVerbose( "Repository Start-End Rev no : %d-%d" % (startrevno, endrevno)) self.ConvertRevs(startrevno, endrevno, bUpdLineCount) # every thing is ok. Commit the changes. self.db.commit() except Exception, expinst: logging.exception("Found Error") self.svnexception_handler(expinst) print "Trying again (%d)" % (trycount + 1) self.closedb()