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
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