Exemple #1
0
    def test_branching_file_paths(self):
        # This part should be moved to set up, but in case no one from MetricsGrimoire
        # is interested in this pull request (which is the case for all my pull requests
        # so far), it is easier to keep compatible with the main repository this way
        opened, temp_file_name = tempfile.mkstemp('.db', 'cvsanaly-test')
        os.close(opened)
        command_line_options = ["--db-driver=sqlite", "-d", temp_file_name, self.TEST_REPOSITORY_PATH]
        pycvsanaly2.main.main(command_line_options)

        connection = db.connect(temp_file_name)
        cursor = connection.cursor()
        cursor.execute('SELECT id FROM repositories')
        database = create_database('sqlite', temp_file_name)
        fr = FileRevs(database, connection, cursor, cursor.fetchone()[0])
        repo = create_repository_from_path(self.TEST_REPOSITORY_PATH)
        for revision, commit_id, file_id, action_type, composed in fr:
            if revision == '51a3b654f252210572297f47597b31527c475fb8':
                # Getting the latest file_links record
                actual = fr.get_path()
                self.assertEqual(u'aaa/otherthing.renamed', actual)
                # Using git merge-base
                actual = fr.get_path(repo, self.TEST_REPOSITORY_PATH)
                self.assertEqual(u'aaa/otherthing', actual)


        cursor.close()
        connection.close()
        os.remove(temp_file_name)
Exemple #2
0
    def test_branching_file_paths(self):
        # This part should be moved to set up, but in case no one from MetricsGrimoire
        # is interested in this pull request (which is the case for all my pull requests
        # so far), it is easier to keep compatible with the main repository this way
        opened, temp_file_name = tempfile.mkstemp('.db', 'cvsanaly-test')
        os.close(opened)
        command_line_options = [
            "--db-driver=sqlite", "-d", temp_file_name,
            self.TEST_REPOSITORY_PATH
        ]
        pycvsanaly2.main.main(command_line_options)

        connection = db.connect(temp_file_name)
        cursor = connection.cursor()
        cursor.execute('SELECT id FROM repositories')
        database = create_database('sqlite', temp_file_name)
        fr = FileRevs(database, connection, cursor, cursor.fetchone()[0])
        repo = create_repository_from_path(self.TEST_REPOSITORY_PATH)
        for revision, commit_id, file_id, action_type, composed in fr:
            if revision == '51a3b654f252210572297f47597b31527c475fb8':
                # Getting the latest file_links record
                actual = fr.get_path()
                self.assertEqual(u'aaa/otherthing.renamed', actual)
                # Using git merge-base
                actual = fr.get_path(repo, self.TEST_REPOSITORY_PATH)
                self.assertEqual(u'aaa/otherthing', actual)

        cursor.close()
        connection.close()
        os.remove(temp_file_name)
Exemple #3
0
        old_id = -1
        all_commits = [i[0] for i in cursor.fetchall()]
        for id in all_commits:
            if old_id != id:
                self.update_for_revision(cursor, id, repo_id)
                old_id = id
        cursor.close()
        cnn.close()
        profiler_stop("Update all file paths", delete=True)

if __name__ == '__main__':
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    db = create_database('sqlite', sys.argv[1])
    cnn = db.connect()

    fp = FilePaths(db)

    config = Config()
    config.profile = True

    cursor = cnn.cursor()
    cursor.execute(
        "select s.id, file_id from scmlog s, actions a where s.id = a.commit_id"
    )
    old_id = -1
    for id, file_id in cursor.fetchall():
        if old_id != id:
            print "Commit ", id
Exemple #4
0
    def __get_path_from_db(self, file_id, commit_id):
        cursor = self.cnn.cursor()

        cursor.execute(statement(self.__path_query__, self.db.place_holder),
                       (file_id, commit_id))
        path = cursor.fetchone()[0]

        cursor.close()

        return "/" + path


if __name__ == '__main__':
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    config = Config()
    config.load()
    db = create_database(config.db_driver, sys.argv[1], config.db_user,
                         config.db_password, config.db_hostname)
    cnn = db.connect()
    cursor = cnn.cursor()

    fr = FileRevs(db, cnn, cursor, 1)
    for revision, commit_id, file_id, action_type, composed in fr:
        print revision, commit_id, action_type, fr.get_path()

    cursor.close()
    cnn.close()
Exemple #5
0
                        relative_path = file_link[1]
                        break
                    else:
                        file_link = cursor.fetchone()
            except CommandError as e:
                printerr(str(e) + '\n' + e.error)

        cursor.close()
        if relative_path is None:
            return None
        else:
            return relative_path.strip("/")

if __name__ == '__main__':
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    config = Config()
    config.load()
    db = create_database(config.db_driver, sys.argv[1], config.db_user, config.db_password, config.db_hostname)
    cnn = db.connect()
    cursor = cnn.cursor()

    fr = FileRevs(db, cnn, cursor, 1)
    for revision, commit_id, file_id, action_type, composed in fr:
        print revision, commit_id, action_type, fr.get_path()

    cursor.close()
    cnn.close()
Exemple #6
0
            printdbg("Syncing shelf")
            self.__dict__['cached_adj'].sync()
            printdbg("Closing shelf")
            self.__dict__['cached_adj'].close()
            printdbg("Deleting shelve " + self.shelve_file_name)
            os.remove(self.shelve_file_name)
            # Clean up cached adj in case this gets called without
            # update_all later
            self.__dict__['cached_adj'] = {}

if __name__ == '__main__':
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    db = create_database('sqlite', sys.argv[1])
    cnn = db.connect()

    fp = FilePaths(db)

    config = Config()
    config.profile = True

    cursor = cnn.cursor()
    cursor.execute("select s.id, file_id from scmlog s, actions a " + \
                   "where s.id = a.commit_id")
    old_id = -1
    for id, file_id in cursor.fetchall():
        if old_id != id:
            print "Commit ", id
            fp.update_for_revision(cursor, id, 1)
Exemple #7
0
        assert adj is not None, "Matrix no updated"
        try:
            return adj.files[file_id]
        except KeyError:
            return None

    def get_commit_id(self):
        return self.__dict__["rev"]


if __name__ == "__main__":
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    db = create_database("sqlite", sys.argv[1])
    cnn = db.connect()

    fp = FilePaths(db)

    config = Config()
    config.profile = True

    cursor = cnn.cursor()
    cursor.execute("select s.id, file_id from scmlog s, actions a where s.id = a.commit_id")
    old_id = -1
    for id, file_id in cursor.fetchall():
        if old_id != id:
            print "Commit ", id
            fp.update_for_revision(cursor, id, 1)
            old_id = id
Exemple #8
0
        assert adj is not None, "Matrix no updated"
        try:
            return adj.files[file_id]
        except KeyError:
            return None

    def get_commit_id(self):
        return self.__dict__['rev']


if __name__ == '__main__':
    import sys
    from pycvsanaly2.Database import create_database
    from pycvsanaly2.Config import Config

    db = create_database('mysql', sys.argv[1], 'lashchyk', '', 'localhost')
    cnn = db.connect()

    fp = FilePaths(db)

    config = Config()
    config.profile = True

    cursor = cnn.cursor()
    insertCursor = cnn.cursor()

    cursor.execute("select s.id, file_id from scmlog s, actions a where s.id = a.commit_id")
    old_id = -1
    for id, file_id in cursor.fetchall():
        if old_id != id:
            print "Commit ", id
Exemple #9
0
    outputFile = projectName + '.cdif'

    # Configuration & initialisation of output
    cdifWriter.writeMooseCompliantCdif()
    outputHandle = open(outputFile, "w")
    outputHandle.close()
    outputHandle = open(outputFile, "a+")

    EvoCdifWriter.setOutputHandle(outputHandle)
    cdifWriter.set_outputhandle(outputHandle)
    cdifWriter.initializeIDCounter()
    cdifWriter.generateHeader(True, "evofetch", projectName, "4", "C++",
                              "ISO98")

    try:
        db = create_database(driver, database, user, passwd, hostname)
    except AccessDenied, e:
        printerr("Error creating database: %s", (e.message))
        return 1
    except DatabaseNotFound:
        printerr(
            "Database %s doesn't exist. It must be created before running cvsanaly",
            (database))
        return 1
    except DatabaseDriverNotSupported:
        printerr("Database driver %s is not supported by cvsanaly", (driver))
        return 1

    cnn = db.connect()

    try: