Esempio n. 1
0
 def test_object_diff_bin_blob_force(self):
     f = StringIO()
     # Prepare two slightly different PNG headers
     b1 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b")
     b2 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, ('foo.png', 0644, b1.id),
                                 ('bar.png', 0644, b2.id), diff_binary=True)
     self.assertEqual([
         'diff --git a/foo.png b/bar.png',
         'index f73e47d..06364b7 644',
         '--- a/foo.png',
         '+++ b/bar.png',
         '@@ -1,4 +1,4 @@',
         ' \x89PNG',
         ' \x1a',
         ' \x00\x00\x00',
         '-IHDR\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b',
         '\\ No newline at end of file',
         '+IHDR\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3',
         '\\ No newline at end of file'
         ], f.getvalue().splitlines())
 def test_tree_diff_submodule(self):
     f = BytesIO()
     store = MemoryObjectStore()
     tree1 = Tree()
     tree1.add(
         b"asubmodule",
         S_IFGITLINK,
         b"06d0bdd9e2e20377b3180e4986b14c8549b393e4",
     )
     tree2 = Tree()
     tree2.add(
         b"asubmodule",
         S_IFGITLINK,
         b"cc975646af69f279396d4d5e1379ac6af80ee637",
     )
     store.add_objects([(o, None) for o in [tree1, tree2]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual(
         [
             b"diff --git a/asubmodule b/asubmodule",
             b"index 06d0bdd..cc97564 160000",
             b"--- a/asubmodule",
             b"+++ b/asubmodule",
             b"@@ -1 +1 @@",
             b"-Subproject commit 06d0bdd9e2e20377b3180e4986b14c8549b393e4",
             b"+Subproject commit cc975646af69f279396d4d5e1379ac6af80ee637",
         ],
         f.getvalue().splitlines(),
     )
Esempio n. 3
0
 def test_object_diff_bin_blob_force(self):
     f = BytesIO()
     # Prepare two slightly different PNG headers
     b1 = Blob.from_string(
         b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
         b"\x00\x00\x00\x0d\x49\x48\x44\x52"
         b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
         b"\x08\x04\x00\x00\x00\x05\x04\x8b")
     b2 = Blob.from_string(
         b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
         b"\x00\x00\x00\x0d\x49\x48\x44\x52"
         b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
         b"\x08\x03\x00\x00\x00\x98\xd3\xb3")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(
         f, store, (b'foo.png', 0o644, b1.id),
         (b'bar.png', 0o644, b2.id), diff_binary=True)
     self.assertEqual([
         b'diff --git a/foo.png b/bar.png',
         b'index f73e47d..06364b7 644',
         b'--- a/foo.png',
         b'+++ b/bar.png',
         b'@@ -1,4 +1,4 @@',
         b' \x89PNG',
         b' \x1a',
         b' \x00\x00\x00',
         b'-IHDR\x00\x00\x01\xd5\x00\x00\x00'
         b'\x9f\x08\x04\x00\x00\x00\x05\x04\x8b',
         b'\\ No newline at end of file',
         b'+IHDR\x00\x00\x01\xd5\x00\x00\x00\x9f'
         b'\x08\x03\x00\x00\x00\x98\xd3\xb3',
         b'\\ No newline at end of file'
         ], f.getvalue().splitlines())
Esempio n. 4
0
 def test_object_diff_bin_blob_force(self):
     f = BytesIO()
     # Prepare two slightly different PNG headers
     b1 = Blob.from_string(
         b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         b"\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b"
     )
     b2 = Blob.from_string(
         b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         b"\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3"
     )
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, (b"foo.png", 0o644, b1.id), (b"bar.png", 0o644, b2.id), diff_binary=True)
     self.assertEqual(
         [
             b"diff --git a/foo.png b/bar.png",
             b"index f73e47d..06364b7 644",
             b"--- a/foo.png",
             b"+++ b/bar.png",
             b"@@ -1,4 +1,4 @@",
             b" \x89PNG",
             b" \x1a",
             b" \x00\x00\x00",
             b"-IHDR\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b",
             b"\\ No newline at end of file",
             b"+IHDR\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3",
             b"\\ No newline at end of file",
         ],
         f.getvalue().splitlines(),
     )
Esempio n. 5
0
 def test_ff(self):
     store = MemoryObjectStore()
     base = make_commit()
     c1 = make_commit(parents=[base.id])
     c2 = make_commit(parents=[c1.id])
     store.add_objects([(base, None), (c1, None), (c2, None)])
     self.assertTrue(can_fast_forward(store, c1.id, c1.id))
     self.assertTrue(can_fast_forward(store, base.id, c1.id))
     self.assertTrue(can_fast_forward(store, c1.id, c2.id))
     self.assertFalse(can_fast_forward(store, c2.id, c1.id))
Esempio n. 6
0
 def test_diverged(self):
     store = MemoryObjectStore()
     base = make_commit()
     c1 = make_commit(parents=[base.id])
     c2a = make_commit(parents=[c1.id], message=b'2a')
     c2b = make_commit(parents=[c1.id], message=b'2b')
     store.add_objects([(base, None), (c1, None), (c2a, None), (c2b, None)])
     self.assertTrue(can_fast_forward(store, c1.id, c2a.id))
     self.assertTrue(can_fast_forward(store, c1.id, c2b.id))
     self.assertFalse(can_fast_forward(store, c2a.id, c2b.id))
     self.assertFalse(can_fast_forward(store, c2b.id, c2a.id))
 def test_tree_diff(self):
     f = BytesIO()
     store = MemoryObjectStore()
     added = Blob.from_string(b"add\n")
     removed = Blob.from_string(b"removed\n")
     changed1 = Blob.from_string(b"unchanged\nremoved\n")
     changed2 = Blob.from_string(b"unchanged\nadded\n")
     unchanged = Blob.from_string(b"unchanged\n")
     tree1 = Tree()
     tree1.add(b"removed.txt", 0o644, removed.id)
     tree1.add(b"changed.txt", 0o644, changed1.id)
     tree1.add(b"unchanged.txt", 0o644, changed1.id)
     tree2 = Tree()
     tree2.add(b"added.txt", 0o644, added.id)
     tree2.add(b"changed.txt", 0o644, changed2.id)
     tree2.add(b"unchanged.txt", 0o644, changed1.id)
     store.add_objects([(o, None) for o in [
         tree1,
         tree2,
         added,
         removed,
         changed1,
         changed2,
         unchanged,
     ]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual(
         [
             b"diff --git a/added.txt b/added.txt",
             b"new file mode 644",
             b"index 0000000..76d4bb8",
             b"--- /dev/null",
             b"+++ b/added.txt",
             b"@@ -0,0 +1 @@",
             b"+add",
             b"diff --git a/changed.txt b/changed.txt",
             b"index bf84e48..1be2436 644",
             b"--- a/changed.txt",
             b"+++ b/changed.txt",
             b"@@ -1,2 +1,2 @@",
             b" unchanged",
             b"-removed",
             b"+added",
             b"diff --git a/removed.txt b/removed.txt",
             b"deleted file mode 644",
             b"index 2c3f0b3..0000000",
             b"--- a/removed.txt",
             b"+++ /dev/null",
             b"@@ -1 +0,0 @@",
             b"-removed",
         ],
         f.getvalue().splitlines(),
     )
Esempio n. 8
0
 def test_tree_diff(self):
     f = StringIO()
     store = MemoryObjectStore()
     added = Blob.from_string("add\n")
     removed = Blob.from_string("removed\n")
     changed1 = Blob.from_string("unchanged\nremoved\n")
     changed2 = Blob.from_string("unchanged\nadded\n")
     unchanged = Blob.from_string("unchanged\n")
     tree1 = Tree()
     tree1.add(0644, "removed.txt", removed.id)
     tree1.add(0644, "changed.txt", changed1.id)
     tree1.add(0644, "unchanged.txt", changed1.id)
     tree2 = Tree()
     tree2.add(0644, "added.txt", added.id)
     tree2.add(0644, "changed.txt", changed2.id)
     tree1.add(0644, "unchanged.txt", changed1.id)
     store.add_objects([(o, None) for o in [
         tree1, tree2, added, removed, changed1, changed2, unchanged]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEquals([
         'diff --git a/changed.txt b/changed.txt',
         'index bf84e48..1be2436 644',
         '--- a/changed.txt',
         '+++ b/changed.txt',
         '@@ -1,2 +1,2 @@',
         ' unchanged',
         '-removed',
         '+added',
         'diff --git a/removed.txt /dev/null',
         'deleted mode 644',
         'index 2c3f0b3..e69de29',
         '--- a/removed.txt',
         '+++ /dev/null',
         '@@ -1,1 +1,0 @@',
         '-removed',
         'diff --git a/unchanged.txt /dev/null',
         'deleted mode 644',
         'index bf84e48..e69de29',
         '--- a/unchanged.txt',
         '+++ /dev/null',
         '@@ -1,2 +1,0 @@',
         '-unchanged',
         '-removed',
         'diff --git /dev/null b/added.txt',
         'new mode 644',
         'index e69de29..76d4bb8 644',
         '--- /dev/null',
         '+++ b/added.txt',
         '@@ -1,0 +1,1 @@',
         '+add'
         ], f.getvalue().splitlines())
Esempio n. 9
0
 def test_object_diff_blob(self):
     f = BytesIO()
     b1 = Blob.from_string(b"old\nsame\n")
     b2 = Blob.from_string(b"new\nsame\n")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, (b"foo.txt", 0o644, b1.id),
                       (b"bar.txt", 0o644, b2.id))
     self.assertEqual([
         b"diff --git a/foo.txt b/bar.txt", b"index 3b0f961..a116b51 644",
         b"--- a/foo.txt", b"+++ b/bar.txt", b"@@ -1,2 +1,2 @@", b"-old",
         b"+new", b" same"
     ],
                      f.getvalue().splitlines())
Esempio n. 10
0
class GitFastExporterTests(TestCase):
    """Tests for the GitFastExporter tests."""

    def setUp(self):
        super(GitFastExporterTests, self).setUp()
        self.store = MemoryObjectStore()
        self.stream = BytesIO()
        try:
            from dulwich.fastexport import GitFastExporter
        except ImportError:
            raise SkipTest("python-fastimport not available")
        self.fastexporter = GitFastExporter(self.stream, self.store)

    def test_emit_blob(self):
        b = Blob()
        b.data = b"fooBAR"
        self.fastexporter.emit_blob(b)
        self.assertEqual(b"blob\nmark :1\ndata 6\nfooBAR\n", self.stream.getvalue())

    def test_emit_commit(self):
        b = Blob()
        b.data = b"FOO"
        t = Tree()
        t.add(b"foo", stat.S_IFREG | 0o644, b.id)
        c = Commit()
        c.committer = c.author = b"Jelmer <jelmer@host>"
        c.author_time = c.commit_time = 1271345553
        c.author_timezone = c.commit_timezone = 0
        c.message = b"msg"
        c.tree = t.id
        self.store.add_objects([(b, None), (t, None), (c, None)])
        self.fastexporter.emit_commit(c, b"refs/heads/master")
        self.assertEqual(
            b"""blob
mark :1
data 3
FOO
commit refs/heads/master
mark :2
author Jelmer <jelmer@host> 1271345553 +0000
committer Jelmer <jelmer@host> 1271345553 +0000
data 3
msg
M 644 :1 foo
""",
            self.stream.getvalue(),
        )
Esempio n. 11
0
 def test_tree_diff(self):
     f = BytesIO()
     store = MemoryObjectStore()
     added = Blob.from_string(b"add\n")
     removed = Blob.from_string(b"removed\n")
     changed1 = Blob.from_string(b"unchanged\nremoved\n")
     changed2 = Blob.from_string(b"unchanged\nadded\n")
     unchanged = Blob.from_string(b"unchanged\n")
     tree1 = Tree()
     tree1.add(b"removed.txt", 0o644, removed.id)
     tree1.add(b"changed.txt", 0o644, changed1.id)
     tree1.add(b"unchanged.txt", 0o644, changed1.id)
     tree2 = Tree()
     tree2.add(b"added.txt", 0o644, added.id)
     tree2.add(b"changed.txt", 0o644, changed2.id)
     tree2.add(b"unchanged.txt", 0o644, changed1.id)
     store.add_objects([
         (o, None) for o in
         [tree1, tree2, added, removed, changed1, changed2, unchanged]
     ])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual([
         b'diff --git /dev/null b/added.txt',
         b'new mode 644',
         b'index 0000000..76d4bb8 644',
         b'--- /dev/null',
         b'+++ b/added.txt',
         b'@@ -1,0 +1,1 @@',
         b'+add',
         b'diff --git a/changed.txt b/changed.txt',
         b'index bf84e48..1be2436 644',
         b'--- a/changed.txt',
         b'+++ b/changed.txt',
         b'@@ -1,2 +1,2 @@',
         b' unchanged',
         b'-removed',
         b'+added',
         b'diff --git a/removed.txt /dev/null',
         b'deleted mode 644',
         b'index 2c3f0b3..0000000',
         b'--- a/removed.txt',
         b'+++ /dev/null',
         b'@@ -1,1 +1,0 @@',
         b'-removed',
     ],
                      f.getvalue().splitlines())
Esempio n. 12
0
class GitFastExporterTests(TestCase):
    """Tests for the GitFastExporter tests."""

    def setUp(self):
        super(GitFastExporterTests, self).setUp()
        self.store = MemoryObjectStore()
        self.stream = StringIO()
        try:
            from dulwich.fastexport import GitFastExporter
        except ImportError:
            raise TestSkipped("python-fastimport not available")
        self.fastexporter = GitFastExporter(self.stream, self.store)

    def test_emit_blob(self):
        b = Blob()
        b.data = "fooBAR"
        self.fastexporter.emit_blob(b)
        self.assertEquals('blob\nmark :1\ndata 6\nfooBAR\n',
            self.stream.getvalue())

    def test_emit_commit(self):
        b = Blob()
        b.data = "FOO"
        t = Tree()
        t.add(stat.S_IFREG | 0644, "foo", b.id)
        c = Commit()
        c.committer = c.author = "Jelmer <jelmer@host>"
        c.author_time = c.commit_time = 1271345553
        c.author_timezone = c.commit_timezone = 0
        c.message = "msg"
        c.tree = t.id
        self.store.add_objects([(b, None), (t, None), (c, None)])
        self.fastexporter.emit_commit(c, "refs/heads/master")
        self.assertEquals("""blob
mark :1
data 3
FOO
commit refs/heads/master
mark :2
author Jelmer <jelmer@host> 1271345553 +0000
committer Jelmer <jelmer@host> 1271345553 +0000
data 3
msg
M 644 1 foo
""", self.stream.getvalue())
Esempio n. 13
0
 def test_tree_diff(self):
     f = BytesIO()
     store = MemoryObjectStore()
     added = Blob.from_string(b"add\n")
     removed = Blob.from_string(b"removed\n")
     changed1 = Blob.from_string(b"unchanged\nremoved\n")
     changed2 = Blob.from_string(b"unchanged\nadded\n")
     unchanged = Blob.from_string(b"unchanged\n")
     tree1 = Tree()
     tree1.add(b"removed.txt", 0o644, removed.id)
     tree1.add(b"changed.txt", 0o644, changed1.id)
     tree1.add(b"unchanged.txt", 0o644, changed1.id)
     tree2 = Tree()
     tree2.add(b"added.txt", 0o644, added.id)
     tree2.add(b"changed.txt", 0o644, changed2.id)
     tree2.add(b"unchanged.txt", 0o644, changed1.id)
     store.add_objects([(o, None) for o in [tree1, tree2, added, removed, changed1, changed2, unchanged]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual(
         [
             b"diff --git /dev/null b/added.txt",
             b"new mode 644",
             b"index 0000000..76d4bb8 644",
             b"--- /dev/null",
             b"+++ b/added.txt",
             b"@@ -1,0 +1,1 @@",
             b"+add",
             b"diff --git a/changed.txt b/changed.txt",
             b"index bf84e48..1be2436 644",
             b"--- a/changed.txt",
             b"+++ b/changed.txt",
             b"@@ -1,2 +1,2 @@",
             b" unchanged",
             b"-removed",
             b"+added",
             b"diff --git a/removed.txt /dev/null",
             b"deleted mode 644",
             b"index 2c3f0b3..0000000",
             b"--- a/removed.txt",
             b"+++ /dev/null",
             b"@@ -1,1 +1,0 @@",
             b"-removed",
         ],
         f.getvalue().splitlines(),
     )
Esempio n. 14
0
 def test_object_diff_bin_blob(self):
     f = BytesIO()
     # Prepare two slightly different PNG headers
     b1 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b")
     b2 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, ('foo.png', 0o644, b1.id),
                       ('bar.png', 0o644, b2.id))
     self.assertEqual([
         'diff --git a/foo.png b/bar.png', 'index f73e47d..06364b7 644',
         'Binary files a/foo.png and b/bar.png differ'
     ],
                      f.getvalue().splitlines())
Esempio n. 15
0
 def test_object_diff_bin_blob(self):
     f = BytesIO()
     # Prepare two slightly different PNG headers
     b1 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x04\x00\x00\x00\x05\x04\x8b")
     b2 = Blob.from_string(
         "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
         "\x00\x00\x01\xd5\x00\x00\x00\x9f\x08\x03\x00\x00\x00\x98\xd3\xb3")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, ('foo.png', 0o644, b1.id),
                                 ('bar.png', 0o644, b2.id))
     self.assertEqual([
         'diff --git a/foo.png b/bar.png',
         'index f73e47d..06364b7 644',
         'Binary files a/foo.png and b/bar.png differ'
         ], f.getvalue().splitlines())
Esempio n. 16
0
 def test_object_diff_blob(self):
     f = BytesIO()
     b1 = Blob.from_string(b"old\nsame\n")
     b2 = Blob.from_string(b"new\nsame\n")
     store = MemoryObjectStore()
     store.add_objects([(b1, None), (b2, None)])
     write_object_diff(f, store, ("foo.txt", 0o644, b1.id),
                                 ("bar.txt", 0o644, b2.id))
     self.assertEqual([
         b"diff --git a/foo.txt b/bar.txt",
         b"index 3b0f961..a116b51 644",
         b"--- a/foo.txt",
         b"+++ b/bar.txt",
         b"@@ -1,2 +1,2 @@",
         b"-old",
         b"+new",
         b" same"
         ], f.getvalue().splitlines())
Esempio n. 17
0
 def test_tree_diff(self):
     f = BytesIO()
     store = MemoryObjectStore()
     added = Blob.from_string(b"add\n")
     removed = Blob.from_string(b"removed\n")
     changed1 = Blob.from_string(b"unchanged\nremoved\n")
     changed2 = Blob.from_string(b"unchanged\nadded\n")
     unchanged = Blob.from_string(b"unchanged\n")
     tree1 = Tree()
     tree1.add(b"removed.txt", 0o644, removed.id)
     tree1.add(b"changed.txt", 0o644, changed1.id)
     tree1.add(b"unchanged.txt", 0o644, changed1.id)
     tree2 = Tree()
     tree2.add(b"added.txt", 0o644, added.id)
     tree2.add(b"changed.txt", 0o644, changed2.id)
     tree2.add(b"unchanged.txt", 0o644, changed1.id)
     store.add_objects([(o, None) for o in [
         tree1, tree2, added, removed, changed1, changed2, unchanged]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual([
         b'diff --git a/added.txt b/added.txt',
         b'new file mode 644',
         b'index 0000000..76d4bb8',
         b'--- /dev/null',
         b'+++ b/added.txt',
         b'@@ -0,0 +1 @@',
         b'+add',
         b'diff --git a/changed.txt b/changed.txt',
         b'index bf84e48..1be2436 644',
         b'--- a/changed.txt',
         b'+++ b/changed.txt',
         b'@@ -1,2 +1,2 @@',
         b' unchanged',
         b'-removed',
         b'+added',
         b'diff --git a/removed.txt b/removed.txt',
         b'deleted file mode 644',
         b'index 2c3f0b3..0000000',
         b'--- a/removed.txt',
         b'+++ /dev/null',
         b'@@ -1 +0,0 @@',
         b'-removed',
         ], f.getvalue().splitlines())
Esempio n. 18
0
class FastExporterTests(TestCase):

    def setUp(self):
        super(FastExporterTests, self).setUp()
        self.store = MemoryObjectStore()
        self.stream = StringIO()
        self.fastexporter = FastExporter(self.stream, self.store)

    def test_export_blob(self):
        b = Blob()
        b.data = "fooBAR"
        self.assertEquals(1, self.fastexporter.export_blob(b))
        self.assertEquals('blob\nmark :1\ndata 6\nfooBAR\n',
            self.stream.getvalue())

    def test_export_commit(self):
        b = Blob()
        b.data = "FOO"
        t = Tree()
        t.add(stat.S_IFREG | 0644, "foo", b.id)
        c = Commit()
        c.committer = c.author = "Jelmer <jelmer@host>"
        c.author_time = c.commit_time = 1271345553.47
        c.author_timezone = c.commit_timezone = 0
        c.message = "msg"
        c.tree = t.id
        self.store.add_objects([(b, None), (t, None), (c, None)])
        self.assertEquals(2,
                self.fastexporter.export_commit(c, "refs/heads/master"))
        self.assertEquals("""blob
mark :1
data 3
FOO
commit refs/heads/master
mark :2
author Jelmer <jelmer@host> 1271345553.47 +0000
committer Jelmer <jelmer@host> 1271345553.47 +0000
data 3
msg
M 100644 :1 foo

""", self.stream.getvalue())
Esempio n. 19
0
 def test_tree_diff_submodule(self):
     f = BytesIO()
     store = MemoryObjectStore()
     tree1 = Tree()
     tree1.add("asubmodule", S_IFGITLINK,
         "06d0bdd9e2e20377b3180e4986b14c8549b393e4")
     tree2 = Tree()
     tree2.add("asubmodule", S_IFGITLINK,
         "cc975646af69f279396d4d5e1379ac6af80ee637")
     store.add_objects([(o, None) for o in [tree1, tree2]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual([
         'diff --git a/asubmodule b/asubmodule',
         'index 06d0bdd..cc97564 160000',
         '--- a/asubmodule',
         '+++ b/asubmodule',
         '@@ -1,1 +1,1 @@',
         '-Submodule commit 06d0bdd9e2e20377b3180e4986b14c8549b393e4',
         '+Submodule commit cc975646af69f279396d4d5e1379ac6af80ee637',
         ], f.getvalue().splitlines())
Esempio n. 20
0
 def test_tree_diff_submodule(self):
     f = BytesIO()
     store = MemoryObjectStore()
     tree1 = Tree()
     tree1.add(b"asubmodule", S_IFGITLINK,
         Sha1Sum("06d0bdd9e2e20377b3180e4986b14c8549b393e4"))
     tree2 = Tree()
     tree2.add(b"asubmodule", S_IFGITLINK,
         Sha1Sum("cc975646af69f279396d4d5e1379ac6af80ee637"))
     store.add_objects([(o, None) for o in [tree1, tree2]])
     write_tree_diff(f, store, tree1.id, tree2.id)
     self.assertEqual([
         b'diff --git a/asubmodule b/asubmodule',
         b'index 06d0bdd..cc97564 160000',
         b'--- a/asubmodule',
         b'+++ b/asubmodule',
         b'@@ -1,1 +1,1 @@',
         b'-Submodule commit 06d0bdd9e2e20377b3180e4986b14c8549b393e4',
         b'+Submodule commit cc975646af69f279396d4d5e1379ac6af80ee637',
         ], f.getvalue().splitlines())