From e83796cd9460011925157f39aa0eb1ab105e16c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Mon, 13 Mar 2023 23:54:55 +0000 Subject: [PATCH] Fix fetching into MemoryRepo Fixes #1157 --- NEWS | 2 ++ dulwich/object_store.py | 10 ++++++++++ dulwich/tests/test_repository.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index 5be495267..43ced4d67 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ * Deprecate ``dulwich.objects.parse_commit``. + * Fix fetching into MemoryRepo. (Jelmer Vernooij, #1157) + 0.21.3 2023-02-17 * Add support for ``worktreeconfig`` extension. diff --git a/dulwich/object_store.py b/dulwich/object_store.py index 8888696eb..4446c7593 100644 --- a/dulwich/object_store.py +++ b/dulwich/object_store.py @@ -1048,6 +1048,16 @@ def abort(): return f, commit, abort + def add_pack_data(self, count: int, unpacked_objects: Iterator[UnpackedObject], progress=None) -> None: + """Add pack data to this object store. + + Args: + count: Number of items to add + pack_data: Iterator over pack data tuples + """ + for unpacked_object in unpacked_objects: + self.add_object(unpacked_object.sha_file()) + def add_thin_pack(self, read_all, read_some, progress=None): """Add a new thin pack to this object store. diff --git a/dulwich/tests/test_repository.py b/dulwich/tests/test_repository.py index 7fa631a18..bcb827796 100644 --- a/dulwich/tests/test_repository.py +++ b/dulwich/tests/test_repository.py @@ -124,6 +124,12 @@ def test_set_description(self): r.set_description(description) self.assertEqual(description, r.get_description()) + def test_pull_into(self): + r = MemoryRepo.init_bare([], {}) + repo = open_repo("a.git") + self.addCleanup(tear_down_repo, repo) + repo.fetch(r) + class RepositoryRootTests(TestCase): def mkdtemp(self):