Exemple #1
0
    def construct_historage(self):
        logger.info('convert a git repository to a  historage...')

        historage_repo = self.prepare_historage_repo()
        committer = SyntaxTreesCommitter(Repo(self.org_repo.git_dir), historage_repo, self.syntax_trees_dir)
        num_commits = self.num_commits if self.num_commits != 0 else '???'
        for num, commit in izip(count(), get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs)):
            logger.info('[%d/%s] convert %s to: %s' % (num, num_commits, commit.hexsha, historage_repo.git_dir))
            committer.apply_change(commit)
        committer.create_heads()
        committer.create_tags()
        if not self.is_bare_repo:
            historage_repo.head.reset(working_tree=True)
        logger.info('completed!')
Exemple #2
0
    def construct_historage(self):
        print 'create historage...'

        base_repo = self.prepare_base_repo()
        committer = SyntaxTreesCommitter(Repo(self.org_repo.git_dir), base_repo, self.syntax_trees_dir)
        num_commits = self.num_commits if self.num_commits != 0 else '???'
        for num, commit in izip(count(), get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs)):
            commit = self.org_repo.commit(commit)
            print '[%d/%s] convert %s to: %s' % (num, num_commits, commit.hexsha, base_repo.git_dir)
            committer.apply_change(commit)
        committer.create_heads()
        committer.create_tags()
        if not self.is_bare_repo:
            base_repo.head.reset(working_tree=True)
Exemple #3
0
    def construct_historage(self):
        logger.info('convert a git repository to a  historage...')

        historage_repo = self.prepare_historage_repo()
        committer = SyntaxTreesCommitter(Repo(self.org_repo.git_dir),
                                         historage_repo, self.syntax_trees_dir)
        num_commits = self.num_commits if self.num_commits != 0 else '???'
        for num, commit in zip(
                count(),
                get_reversed_topological_ordered_commits(
                    self.org_repo, self.org_repo.refs)):
            logger.info(
                '[%d/%s] convert %s to: %s' %
                (num, num_commits, commit.hexsha, historage_repo.git_dir))
            committer.apply_change(commit)
        committer.create_heads()
        committer.create_tags()
        if not self.is_bare_repo:
            historage_repo.head.reset(working_tree=True)
        logger.info('completed!')
Exemple #4
0
 def parse_all_target_files(self):
     logger.info('create parser processes...')
     blob_parser = BlobParser(extension_dict, self.syntax_trees_dir, self.org_repo.git_dir)
     parsed_blob = set()
     for commit in get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs):
         self.num_commits = self.num_commits + 1
         if commit.parents:
             for p in commit.parents:
                 for diff in p.diff(commit):
                     if is_target_blob(diff.b_blob):
                         if diff.b_blob.hexsha not in parsed_blob:
                             blob_parser.parse_blob(diff.b_blob)
                             parsed_blob.add(diff.b_blob.hexsha)
         else:
             for entry in commit.tree.traverse():
                 if isinstance(entry, Blob) and is_target_blob(entry):
                     if entry.hexsha not in parsed_blob:
                         blob_parser.parse_blob(entry)
                         parsed_blob.add(entry.hexsha)
     logger.info('waiting parser processes')
     blob_parser.join()
Exemple #5
0
 def parse_all_java_files(self):
     print 'create paresr processes...'
     parser_executor = ParserExecutor(self.syntax_trees_dir, self.parser_jar_path)
     parsed_blob = set()
     for commit in get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs):
         self.num_commits = self.num_commits + 1
         commit = self.org_repo.commit(commit)
         if commit.parents:
             for p in commit.parents:
                 for diff in p.diff(commit):
                     if self.is_target_blob(diff.b_blob, '.java'):
                         if diff.b_blob.hexsha not in parsed_blob:
                             parser_executor.parse_blob(diff.b_blob)
                             parsed_blob.add(diff.b_blob.hexsha)
         else:
             for entry in commit.tree.traverse():
                 if isinstance(entry, Blob) and self.is_target_blob(entry, '.java'):
                     if entry.hexsha not in parsed_blob:
                         parser_executor.parse_blob(entry)
                         parsed_blob.add(entry.hexsha)
     print 'waiting parser processes'
     parser_executor.join()
Exemple #6
0
 def parse_all_target_files(self):
     logger.info('create parser processes...')
     blob_parser = BlobParser(extension_dict, self.syntax_trees_dir,
                              self.org_repo.git_dir)
     parsed_blob = set()
     for commit in get_reversed_topological_ordered_commits(
             self.org_repo, self.org_repo.refs):
         self.num_commits = self.num_commits + 1
         if commit.parents:
             for p in commit.parents:
                 for diff in p.diff(commit):
                     if is_target_blob(diff.b_blob):
                         if diff.b_blob.hexsha not in parsed_blob:
                             blob_parser.parse_blob(diff.b_blob)
                             parsed_blob.add(diff.b_blob.hexsha)
         else:
             for entry in commit.tree.traverse():
                 if isinstance(entry, Blob) and is_target_blob(entry):
                     if entry.hexsha not in parsed_blob:
                         blob_parser.parse_blob(entry)
                         parsed_blob.add(entry.hexsha)
     logger.info('waiting parser processes')
     blob_parser.join()
Exemple #7
0
    submodule_conf = "/Users/kenjif/test_gitmodules"
    conf_mode, conf_binsha = write_blob(odb, submodule_conf)
    tree_contents = []
    tree_contents.append((conf_mode, conf_binsha, ".gitmodules"))
    tree_contents.append(get_submodule_tree_content(submodule_commit_hexsha, "jEdit"))

    tree_mode, binsha = mktree_from_iter(odb, tree_contents)
    return bin_to_hex(binsha)


if __name__ == "__main__":
    from kenja.git.util import get_reversed_topological_ordered_commits

    repo = Repo("/Users/kenjif/msr_repos/git/jEdit")

    commits = get_reversed_topological_ordered_commits(repo, repo.refs)

    new_repo = Repo.init("/Users/kenjif/test_git_repo")

    with open("/Users/kenjif/test_gitmodules", "wb") as f:
        name = "jEdit"
        path = "jEdit"
        url = "/Users/kenjif/msr_repos/git/jEdit"
        write_submodule_config(f, name, path, url)

    committed = {}
    tags = {}
    heads = {}
    for tag_ref in repo.tags:
        tags[tag_ref.commit.hexsha] = tag_ref.name