diff --git a/swh/loader/bzr/loader.py b/swh/loader/bzr/loader.py index 6b4a8ccec0422f6f44d4a4a322025d144b7208e0..0823c91f60fa40c7bfeb924d0cd0f9b544c5a843 100644 --- a/swh/loader/bzr/loader.py +++ b/swh/loader/bzr/loader.py @@ -54,29 +54,6 @@ EXTID_VERSION: int = 1 T = TypeVar("T") -# These are all the old Bazaar repository formats that we might encounter -# in the wild. Bazaar's `clone` does not result in an upgrade, it needs to be -# explicit. -older_repository_formats = { - b"Bazaar Knit Repository Format 3 (bzr 0.15)\n", - b"Bazaar Knit Repository Format 4 (bzr 1.0)\n", - b"Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n", - b"Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n", - b"Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n", - b"Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n", - b"Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n", - b"Bazaar development format 2 with subtree support \ - (needs bzr.dev from before 1.8)\n", - b"Bazaar development format 8\n", - b"Bazaar pack repository format 1 (needs bzr 0.92)\n", - b"Bazaar pack repository format 1 with rich root (needs bzr 1.0)\n", - b"Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n", - b"Bazaar-NG Knit Repository Format 1", -} - -# Latest one as of this time, unlikely to change -expected_repository_format = b"Bazaar repository format 2a (needs bzr 1.16 or later)\n" - class UnknownRepositoryFormat(Exception): """The repository we're trying to load is using an unknown format. @@ -283,18 +260,16 @@ class BazaarLoader(BaseLoader): self._repo_directory = self.directory branch = self.get_branch() - repository_format = branch.repository._format.get_format_string() - if not repository_format == expected_repository_format: - if repository_format in older_repository_formats: - self.log.debug( - "Upgrading repository from format '%s'", - repository_format.decode("ascii").strip("\n"), - ) - self.run_upgrade() - branch = self.get_branch() - else: - raise UnknownRepositoryFormat() + repository_format = branch.repository._format + + if repository_format.upgrade_recommended: + self.log.debug( + "Upgrading repository from format '%s'", + repository_format.get_format_description() + ) + self.run_upgrade() + branch = self.get_branch() if not branch.supports_tags(): # Some repos have the right format marker but their branches do not