Dulwich.io dulwich / 5c8b327
Check core.repositoryformatversion. Jelmer Vernooń≥ 17 days ago
3 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 0.27.7 UNRELEASED
1
2 * Check core.repositoryformatversion. (Jelmer Vernooń≥, #803)
3
04 0.20.6 2020-08-29
15
26 * Add a ``RefsContainer.watch`` interface.
962962 return cs[len("gitdir: "):].rstrip("\n")
963963
964964
965 class UnsupportedVersion(Exception):
966 """Unsupported repository version."""
967
968 def __init__(self, version):
969 self.version = version
970
971
965972 class Repo(BaseRepo):
966973 """A git repository backed by local disk.
967974
10001007 self._commondir = self._controldir
10011008 self.path = root
10021009 config = self.get_config()
1010 try:
1011 format_version = int(config.get("core", "repositoryformatversion"))
1012 except KeyError:
1013 format_version = 0
1014 if format_version != 0:
1015 raise UnsupportedVersion(format_version)
10031016 object_store = DiskObjectStore.from_config(
10041017 os.path.join(self.commondir(), OBJECTDIR),
10051018 config)
4040 Repo,
4141 MemoryRepo,
4242 check_user_identity,
43 UnsupportedVersion,
4344 )
4445 from dulwich.tests import (
4546 TestCase,
871872 r = Repo(self._repo_dir)
872873 self.assertEqual(r.object_store.loose_compression_level, 4)
873874
875 def test_repositoryformatversion(self):
876 r = self._repo
877 c = r.get_config()
878 c.set(('core',), 'repositoryformatversion', '2')
879 c.write_to_path()
880 self.assertRaises(UnsupportedVersion, Repo, self._repo_dir)
881
874882 def test_commit_encoding_from_config(self):
875883 r = self._repo
876884 c = r.get_config()