Problem
Borg 2.x code is tangled with 1.x legacy code across ~15 files. manifest.py has 15+ if not self.legacy: branches in the Archives class alone. legacyrepository.py and legacyremote.py already have "legacy" in the name but sit at the package root. src/borg/legacy/ exists but is empty.
What this does
Move the bulk of 1.x code into src/borg/legacy/. The goal is to eliminate almost every last # legacy comment , some one-liner branches are worse to extract than to keep. But the major classes and branch-heavy code (LegacyRepository, LegacyRemoteRepository, RepoObj1, the 4 legacy key types, the entire Archives legacy path) all move out.
After this:
- v2 core modules are mostly free of legacy code
borg transfer --from-borg1 keeps working via borg.legacy
- Dropping v1 support later = delete
borg.legacy + remove a handful of scattered one-liners
Plan (6 phases)
Each phase is a separate PR.
| Phase |
What happens |
| 1 |
git mv of legacyrepository.py + legacyremote.py into legacy/ |
| 2 |
Extract RepoObj1, move legacy key types (KeyfileKey, RepoKey, etc.) into legacy/ with duplicated base classes |
| 3 |
Extract LegacyArchives from Archives, remove all self.legacy branches in manifest.py |
| 4 |
Switch remote.py to lazy-import LegacyRepository only inside RepositoryServer.open() |
| 5 |
git mv of upgrade.py into legacy/ |
| 6 |
Inventory remaining scattered legacy markers, split what can be split, document what stays |
Phase 1 + 2.1 (RepoObj1) done in #9559.
Target structure
src/borg/legacy/
├── __init__.py
├── repository.py ← LegacyRepository
├── remote.py ← LegacyRemoteRepository
├── repoobj.py ← RepoObj1
├── manifest.py ← LegacyArchives
├── upgrade.py ← UpgraderFrom12To20, UpgraderNoOp
└── crypto/
├── __init__.py
└── key.py ← Legacy AES-CTR key types (self-contained, duplicated bases)
Some scattered one-liners can't be moved like version == 1 checks in archive.py, legacy exit codes in helpers/errors.py, repository.version == 1 in cache.py. As extracting those would mean duplicating entire methods for one branch. They go away when v1 support is dropped.
Constraints
Testing
python -m pytest src/borg/testsuite/ -x -v
python -m pytest src/borg/testsuite/ -x -v -k "transfer"
Problem
Borg 2.x code is tangled with 1.x legacy code across ~15 files.
manifest.pyhas 15+if not self.legacy:branches in theArchivesclass alone.legacyrepository.pyandlegacyremote.pyalready have "legacy" in the name but sit at the package root.src/borg/legacy/exists but is empty.What this does
Move the bulk of 1.x code into
src/borg/legacy/. The goal is to eliminate almost every last# legacycomment , some one-liner branches are worse to extract than to keep. But the major classes and branch-heavy code (LegacyRepository, LegacyRemoteRepository, RepoObj1, the 4 legacy key types, the entire Archives legacy path) all move out.After this:
borg transfer --from-borg1keeps working viaborg.legacyborg.legacy+ remove a handful of scattered one-linersPlan (6 phases)
Each phase is a separate PR.
git mvoflegacyrepository.py+legacyremote.pyintolegacy/RepoObj1, move legacy key types (KeyfileKey,RepoKey, etc.) intolegacy/with duplicated base classesLegacyArchivesfromArchives, remove allself.legacybranches inmanifest.pyremote.pyto lazy-importLegacyRepositoryonly insideRepositoryServer.open()git mvofupgrade.pyintolegacy/Phase 1 + 2.1 (RepoObj1) done in #9559.
Target structure
Some scattered one-liners can't be moved like
version == 1checks inarchive.py, legacy exit codes inhelpers/errors.py,repository.version == 1incache.py. As extracting those would mean duplicating entire methods for one branch. They go away when v1 support is dropped.Constraints
borg transfer --from-borg1must keep working after every phaseborg servemust handle both v1 and v2 clients (lazy import inRepositoryServer.open())git mvfor whole-file moves (per feedback on legacy: move LegacyRepository, LegacyRemoteRepository, RepoObj1 into borg.legacy package, refs #9556 #9559). Re-exports only where the original file still has v2 code (repoobj.py)Testing
python -m pytest src/borg/testsuite/ -x -v python -m pytest src/borg/testsuite/ -x -v -k "transfer"