archiver: v4-only for -r/--repo, accept v4 in --other-repo, fix TypeError in error message

This commit is contained in:
Mrityunjay Raj 2026-06-01 16:52:41 +05:30
parent 395939b551
commit 2561acdba3

View file

@ -127,9 +127,9 @@ def with_repository(
)
with repository:
if repository.version not in (3, 4):
if repository.version not in (4,):
raise Error(
f"This borg version only accepts version 3 or 4 repos for -r/--repo, "
f"This borg version only accepts version 4 repos for -r/--repo, "
f"but not version {repository.version}. "
f"You can use 'borg transfer' to copy archives from old to new repos."
)
@ -194,10 +194,10 @@ def with_other_repository(manifest=False, cache=False, compatibility=None):
)
with repository:
acceptable_versions = (1,) if v1_legacy else (3,)
acceptable_versions = (1,) if v1_legacy else (3, 4)
if repository.version not in acceptable_versions:
raise Error(
f"This borg version only accepts version {' or '.join(acceptable_versions)} "
f"This borg version only accepts version {' or '.join(str(v) for v in acceptable_versions)} "
f"repos for --other-repo."
)
kwargs["other_repository"] = repository