当前位置: 首页>>代码示例>>Python>>正文


Python IndexFile.write_tree方法代码示例

本文整理汇总了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
开发者ID:ghtdak,项目名称:gitreformat,代码行数:62,代码来源:gitreformat.py


注:本文中的git.IndexFile.write_tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。