1 # test_pack.py -- Compatibility tests for git packs.
2 # Copyright (C) 2010 Google, Inc.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 2
7 # of the License or (at your option) any later version of
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 """Compatibility tests for git packs."""
28 from dulwich.pack import (
31 from dulwich.tests.test_pack import (
41 class TestPack(PackTests):
42 """Compatibility tests for reading and writing pack files."""
45 require_git_version((1, 5, 0))
47 self._tempdir = tempfile.mkdtemp()
50 shutil.rmtree(self._tempdir)
51 PackTests.tearDown(self)
54 origpack = self.get_pack(pack1_sha)
55 self.assertSucceeds(origpack.index.check)
56 pack_path = os.path.join(self._tempdir, "Elch")
57 write_pack(pack_path, [(x, "") for x in origpack.iterobjects()],
60 returncode, output = run_git(['verify-pack', '-v', pack_path],
62 self.assertEquals(0, returncode)
65 for line in output.splitlines():
68 binascii.unhexlify(sha)
70 continue # non-sha line
72 orig_shas = set(o.id for o in origpack.iterobjects())
73 self.assertEquals(orig_shas, pack_shas)