Beispiel #1
0
	def commit(self, message, parent_commits=None, head=True):
		"""Commit the current default index file, creating a commit object.

		For more information on the arguments, see tree.commit.
		:note:
			If you have manually altered the .entries member of this instance,
			don't forget to write() your changes to disk beforehand.

		:return:
			Commit object representing the new commit"""
		tree = self.write_tree()
		return Commit.create_from_tree(self.repo, tree, message, parent_commits, head)
Beispiel #2
0
	def commit(self, message, parent_commits=None, head=True):
		"""Commit the current default index file, creating a commit object.

		For more information on the arguments, see tree.commit.
		:note:
			If you have manually altered the .entries member of this instance,
			don't forget to write() your changes to disk beforehand.

		:return:
			Commit object representing the new commit"""
		tree = self.write_tree()
		return Commit.create_from_tree(self.repo, tree, message, parent_commits, head)
Beispiel #3
0
    def commit(self, message, parent_commits=None, head=True, author=None,
               committer=None, author_date=None, commit_date=None):
        """Commit the current default index file, creating a commit object.
        For more information on the arguments, see tree.commit.

        :note: If you have manually altered the .entries member of this instance,
               don't forget to write() your changes to disk beforehand.
        :return: Commit object representing the new commit"""
        run_commit_hook('pre-commit', self)
        tree = self.write_tree()
        rval = Commit.create_from_tree(self.repo, tree, message, parent_commits,
                                       head, author=author, committer=committer,
                                       author_date=author_date, commit_date=commit_date)
        run_commit_hook('post-commit', self)
        return rval
Beispiel #4
0
def commit_from_binsha(repo, binsha, org_commit, parents=None):
    tree = Tree.new(repo, bin_to_hex(binsha))

    env = os.environ

    offset = altz_to_utctz_str(org_commit.author_tz_offset)
    date = org_commit.authored_date
    env[Commit.env_author_date] = '{} {}'.format(date, offset)

    offset = altz_to_utctz_str(org_commit.committer_tz_offset)
    date = org_commit.committed_date
    env[Commit.env_committer_date] = '{} {}'.format(date, offset)

    return Commit.create_from_tree(repo, tree, org_commit.message, parents,
                                   head=True,
                                   author=org_commit.author,
                                   committer=org_commit.committer)
Beispiel #5
0
def commit_from_binsha(repo, binsha, org_commit, parents=None):
    env = os.environ

    author_date = "%d %s" % (org_commit.authored_date, altz_to_utctz_str(org_commit.author_tz_offset))
    env[Commit.env_author_date] = author_date

    committer_date = "%d %s" % (org_commit.committed_date, altz_to_utctz_str(org_commit.committer_tz_offset))
    env[Commit.env_committer_date] = committer_date

    env[Actor.env_author_name] = org_commit.author.name.encode(org_commit.encoding)
    env[Actor.env_author_email] = org_commit.author.email or ""

    env[Actor.env_committer_name] = org_commit.committer.name.encode(org_commit.encoding)
    env[Actor.env_committer_email] = org_commit.committer.email or ""

    message = org_commit.message.encode(org_commit.encoding)

    tree = Tree.new(repo, bin_to_hex(binsha))

    return Commit.create_from_tree(repo, tree, message, parents, True)
Beispiel #6
0
        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

    for head in repo.heads:
        heads[head.commit.hexsha] = head.name

    for commit_hexsha, num in izip(commits, count()):
        print num, commit_hexsha
        git = new_repo.git
        commit = repo.commit(commit_hexsha)

        parents = []
        for parent in commit.parents:
            parents.append(committed[parent.hexsha])

        message = "[%s] from %s" % (num, commit_hexsha)
        new_tree = create_submodule_tree(new_repo.odb, commit_hexsha)
        new_commit = Commit.create_from_tree(new_repo, new_tree, message, parents)
        if commit_hexsha in tags:
            new_repo.create_tag(tags[commit_hexsha], ref=new_commit)
        if commit_hexsha in heads:
            new_repo.create_head(heads[commit_hexsha], commit=new_commit)
        committed[commit_hexsha] = new_commit
Beispiel #7
0
        children = []
        for parent in commit.parents:
            if parent.hexsha not in visited:
                children.append(parent.hexsha)

        if children:
            nodes.extend(children)
        else:
            nodes.pop()
            visited.add(node)
            post.append(node)

    return post


if __name__ == '__main__':
    repo = Repo.init('test_git')
    # (mode, binsha) = write_tree(repo.odb, 'temp')

    # (mode, binsha) = write_tree(repo.odb, 'temp/00')
    # (mode, binsha) = write_tree(repo.odb, 'temp/01')

    paths = ['temp/00', 'temp/01']
    names = ['a', 'b']

    (mode, binsha) = write_paths(repo.odb, paths, names)

    tree = Tree.new(repo, bin_to_hex(binsha))
    c = Commit.create_from_tree(repo, tree, 'test commit', None, True)