コード例 #1
0
    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

        self.fp = FilePaths (db)
        self.fp.update_all(repoid)
コード例 #2
0
        job_pool = JobPool(repo, path or repo.get_uri(), queuesize=100)

        outer_query = """select distinct h.file_id, h.commit_id
            from hunks h, scmlog s
            where h.commit_id=s.id and s.repository_id=?
                and s.is_bug_fix=1
                and h.old_start_line is not null 
                and h.old_end_line is not null
                and h.file_id is not null
                and h.commit_id is not null
        """
        read_cursor.execute(statement(outer_query, db.place_holder),
                            (repoid, ))
        file_rev = read_cursor.fetchone()
        n_blames = 0
        fp = FilePaths(db)
        fp.update_all(repoid)
        while file_rev is not None:
            try:
                file_id, commit_id = file_rev
                pre_commit_id, pre_rev = self.__find_previous_commit(
                    file_id, commit_id)
                relative_path = fp.get_path(file_id, pre_commit_id, repoid)
                if relative_path is None:
                    raise NotValidHunkWarning(
                        "Couldn't find path for file ID %d" % file_id)
                printdbg("Path for %d at %s -> %s",
                         (file_id, pre_rev, relative_path))

                try:
                    inner_cursor = cnn.cursor()
コード例 #3
0
class FileRevs:

    INTERVAL_SIZE = 1000
    __query__ = '''select s.rev rev, s.id commit_id, af.file_id, af.action_type, s.composed_rev 
        from scmlog s, action_files af 
        where s.id = af.commit_id and s.repository_id = ? 
        order by s.date'''

    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

        self.fp = FilePaths (db)
        self.fp.update_all(repoid)

    def __iter__ (self):
        return self

    def __get_next (self):
        try:
            t = self.rs.next ()
        except StopIteration:
            self.rs = iter (self.icursor.fetchmany ())
            if not self.rs:
                raise StopIteration
            t = self.rs.next ()

        return t

    def next (self):
        if not self.rs:
            raise StopIteration

        while True:
            self.current = self.__get_next ()
            revision, commit_id, file_id, action_type, composed = self.current

            # Should not need to update_for_revision anymore, delete if OK
            # if action_type in ('V', 'C'):
            #     if self.prev_commit != commit_id:
            #         # Get the matrix for revision
            #         self.prev_commit = commit_id
            #         aux_cursor = self.cnn.cursor ()
            #         self.fp.update_for_revision (aux_cursor, commit_id, self.repoid)
            #         aux_cursor.close ()
            #         continue
            # elif action_type == 'D':
            #     continue
            # elif action_type in  ('A', 'R'):
            #     if self.prev_commit != commit_id:
            #         # Get the matrix for revision
            #         self.prev_commit = commit_id
            #         aux_cursor = self.cnn.cursor ()
            #         self.fp.update_for_revision (aux_cursor, commit_id, self.repoid)
            #         aux_cursor.close ()

            return self.current

    def get_path (self):
        if not self.current:
            return None

        revision, commit_id, file_id, action_type, composed = self.current
        if composed:
            rev = revision.split ("|")[0]
        else:
            rev = revision

        try:
            relative_path = self.fp.get_path (file_id, commit_id, self.repoid).strip ("/")
        except AttributeError, e:
            if self.fp.get_commit_id () != commit_id:
                # Commented out as update_for_all exists, delete if OK
                # aux_cursor = self.cnn.cursor ()
                #                 self.fp.update_for_revision (aux_cursor, commit_id, self.repoid)
                #                 aux_cursor.close ()

                relative_path = self.fp.get_path (file_id, commit_id, self.repoid).strip ("/")
            else:
                raise e

        return relative_path
コード例 #4
0
ファイル: HunkBlame.py プロジェクト: jsichi/cvsanaly
        job_pool = JobPool (repo, path or repo.get_uri (), queuesize=100)
        
        outer_query = """select distinct h.file_id, h.commit_id
            from hunks h, scmlog s
            where h.commit_id=s.id and s.repository_id=?
                and s.is_bug_fix=1
                and h.old_start_line is not null 
                and h.old_end_line is not null
                and h.file_id is not null
                and h.commit_id is not null
        """
        read_cursor.execute(statement (outer_query, db.place_holder), (repoid,))
        file_rev = read_cursor.fetchone()
        n_blames = 0
        fp = FilePaths(db)
        fp.update_all(repoid)
        while file_rev is not None:
            try:
                file_id, commit_id = file_rev
                pre_commit_id, pre_rev = self.__find_previous_commit(file_id, commit_id)
                relative_path = fp.get_path(file_id, pre_commit_id, repoid)
                if relative_path is None:
                    raise NotValidHunkWarning("Couldn't find path for file ID %d"%file_id)
                printdbg ("Path for %d at %s -> %s", (file_id, pre_rev, relative_path))
                
                try:
                    inner_cursor = cnn.cursor()
                
                    inner_query = """select h.id, h.old_start_line, h.old_end_line from hunks h
                        where h.file_id = ? and h.commit_id = ?