本文整理汇总了Python中git.IndexFile.write_tree方法的典型用法代码示例。如果您正苦于以下问题:Python IndexFile.write_tree方法的具体用法?Python IndexFile.write_tree怎么用?Python IndexFile.write_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.IndexFile
的用法示例。
在下文中一共展示了IndexFile.write_tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: time_warp
# 需要导入模块: from git import IndexFile [as 别名]
# 或者: from git.IndexFile import write_tree [as 别名]
def time_warp(self, c_o):
"""
History rewriting occurs here. We read everything from the original
commit, reformat the python, and checkin, mirroring the original
commit history.
:param c_o: Commit object representing "before"
:return: None
"""
log.info('warping: {} | {} | {:f} MB | {}s'.format(
time_convert(c_o.authored_date, c_o.author_tz_offset),
c_o.summary,
resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000,
time.clock()))
items = self.handle_commit(c_o)
parent_commits = tuple(self.converted[v] for v in c_o.parents)
# for the singular case of init / root / the genesis
if len(parent_commits) == 0:
parent_commits = {c_o}
self.repo.head.reference = c_o
self.repo.head.reset(index=True, working_tree=True)
idx = IndexFile(self.repo)
idx.add(items)
idx.write_tree()
com_msg = [c_o.message]
com_msg.extend('\n'.join(self.convert_errors))
self.convert_errors = [] # todo: rearchitect - too easy to forget
com_msg.append(
'\n[gitreformat yapf-ify (github/ghtdak) on {}]'.format(
time.strftime('%c')))
com_msg.append('\n[from commit: {}]'.format(c_o.hexsha))
c_n = idx.commit(
''.join(com_msg),
parent_commits=parent_commits,
author=c_o.author,
author_date=time_convert(c_o.authored_date,
c_o.author_tz_offset),
committer=c_o.committer,
commit_date=time_convert(c_o.committed_date,
c_o.committer_tz_offset))
self.repo.head.reference = c_n
self.repo.head.reset(index=True, working_tree=True)
self.verify_paths(c_o.tree, c_n.tree)
self.converted[c_o] = c_n
return c_n