Beispiel #1
0
 def _generate_commit(cls,
                      repository,
                      revision_id,
                      num,
                      total,
                      context=_mod_diff.DEFAULT_CONTEXT_AMOUNT):
     s = BytesIO()
     store = get_object_store(repository)
     with store.lock_read():
         commit = store[repository.lookup_bzr_revision_id(revision_id)[0]]
     from dulwich.patch import write_commit_patch, get_summary
     try:
         lhs_parent = repository.get_revision(revision_id).parent_ids[0]
     except IndexError:
         lhs_parent = _mod_revision.NULL_REVISION
     tree_1 = repository.revision_tree(lhs_parent)
     tree_2 = repository.revision_tree(revision_id)
     contents = BytesIO()
     differ = GitDiffTree.from_trees_options(tree_1,
                                             tree_2,
                                             contents,
                                             'utf8',
                                             None,
                                             'a/',
                                             'b/',
                                             None,
                                             context_lines=context)
     differ.show_diff(None, None)
     write_commit_patch(s, commit, contents.getvalue(), (num, total),
                        version_tail)
     summary = generate_patch_filename(num, get_summary(commit))
     return summary, s.getvalue()
 def test_simple(self):
     c = Commit()
     c.committer = c.author = b"Jelmer <*****@*****.**>"
     c.commit_time = c.author_time = 1271350201
     c.commit_timezone = c.author_timezone = 0
     c.message = b"This is the first line\nAnd this is the second line.\n"
     c.tree = Tree().id
     self.assertEqual("This-is-the-first-line", get_summary(c))