def __init__(self, db, cnn, cursor, repoid): self.db = db self.cnn = cnn self.repoid = repoid self.icursor = ICursor(cursor, self.INTERVAL_SIZE) self.icursor.execute(statement(self.__query__, db.place_holder), (repoid, )) self.rs = iter(self.icursor.fetchmany()) self.prev_commit = -1 self.current = None
def get_patches(self, repo, repo_uri, repo_id, db, cursor): icursor = ICursor(cursor, self.INTERVAL_SIZE) # Get the patches from this repository query = """select p.commit_id, p.file_id, p.patch, s.rev from patches p, scmlog s where p.commit_id = s.id and s.repository_id = ? and p.patch is not NULL""" icursor.execute(statement(query, db.place_holder), (repo_id, )) rs = icursor.fetchmany() while rs: for commit_id, file_id, patch_content, rev in rs: yield (commit_id, file_id, to_utf8(patch_content), rev) rs = icursor.fetchmany()
def patch_generator(repo, repo_uri, repo_id, db, cursor): icursor = ICursor(cursor, self.INTERVAL_SIZE) icursor.execute(statement("SELECT id, rev, composed_rev " + \ "from scmlog where repository_id = ?", db.place_holder), (repo_id,)) rs = icursor.fetchmany() while rs: for commit_id, revision, composed_rev in rs: # Get the patch pj = PatchJob(revision, commit_id) path = uri_to_filename(repo_uri) pj.run(repo, path or repo.get_uri()) p = DBPatch(db, commit_id, pj.data) # Yield the patch to hunks for file_id, patch in p.file_patches(): yield (pj.commit_id, file_id, patch, pj.rev) rs = icursor.fetchmany()
try: self.__create_table(cnn) except TableAlreadyExists: cursor.execute( statement("SELECT max(id) from patches", db.place_holder)) id = cursor.fetchone()[0] if id is not None: DBPatch.id_counter = id + 1 commits = self.__get_patches_for_repository(repo_id, cursor) except Exception, e: raise ExtensionRunError(str(e)) write_cursor = cnn.cursor() icursor = ICursor(cursor, self.INTERVAL_SIZE) icursor.execute( statement( "SELECT id, rev, composed_rev from scmlog where repository_id = ?", db.place_holder), (repo_id, )) rs = icursor.fetchmany() while rs: for commit_id, revision, composed_rev in rs: if commit_id in commits: continue if composed_rev: rev = revision.split("|")[0] else: rev = revision
repo_uri = uri read_cursor.execute(statement( \ "SELECT id from repositories where uri = ?", \ db.place_holder),(repo_uri,)) repo_id = read_cursor.fetchone()[0] except NotImplementedError: raise ExtensionRunError( \ "Content extension is not supported for %s repos" \ %(repo.get_type())) except Exception, e: raise ExtensionRunError( \ "Error creating repository %s. Exception: %s" \ %(repo.get_uri(), str(e))) icursor = ICursor(read_cursor, self.INTERVAL_SIZE) # Get the patches from this repository query = "select p.commit_id, p.patch, s.rev from patches p, scmlog s " + \ "where p.commit_id = s.id and " + \ "s.repository_id = ? and " + \ "p.patch is not NULL" icursor.execute(statement(query, db.place_holder),(repo_id,)) self.__prepare_table(connection) fp = FilePaths(db) fp.update_all(repo_id) rs = icursor.fetchmany() while rs: for commit_id, patch_content, rev in rs: