Add --exclude-archives, the inverse of --match-archives - #10305
Open
m-altaifi wants to merge 2 commits into
Open
Add --exclude-archives, the inverse of --match-archives#10305m-altaifi wants to merge 2 commits into
m-altaifi wants to merge 2 commits into
Conversation
Member
|
Claude? :-) |
❌ 10 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Member
|
@m-altaifi The CI is quite red. Maybe rebase your change onto current master branch and try to fix the failures. |
--match-archives can only narrow a selection: every pattern given must match, so there is no way to say "all archives except these". Doing that needed a shell loop around borg repo-list. Add --exclude-archives, taking the same patterns and selector prefixes. An archive is considered if it matches all --match-archives patterns and none of the --exclude-archives ones, so the new option ORs while the existing one ANDs. The per-pattern matching is factored out of _matching_info_tuples into _matching_by_pattern so both directions share one matcher and all prefixes (aid:, tags:, user:, host:, date:, name:) work for exclusion too. Exclusion patterns are evaluated against all archives rather than the already narrowed list, so an exclusion does not depend on what the inclusion patterns happened to keep. Wired at the shared archive filters group, so every command using define_archive_filters_group gets it. LegacyArchives is updated the same way so borg transfer does not silently ignore the option when reading a borg 1.x repository.
m-altaifi
force-pushed
the
feat/exclude-archives
branch
from
September 3, 2026 20:43
ebdb1a6 to
6117a54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #9936.
--match-archivescan only narrow a selection — all given patterns must match, so there is no way to express "all archives except these" without a shell loop aroundborg repo-list.--exclude-archivestakes the same patterns and the same selector prefixes, and skips any archive matching one of them. An archive is considered if it matches all--match-archivespatterns and none of the--exclude-archivespatterns, i.e. the new option ORs where the existing one ANDs, exactly as--excludedoes for paths:Implementation
The per-pattern matching was inline in
_matching_info_tuples, so I pulled it out into_matching_by_patternand now call it from both directions. That is what makes every prefix —aid:,tags:,user:,host:,date:,name:— work for exclusion as well, rather than exclusion supporting names only.Exclusion patterns are matched against all archives rather than the already-narrowed list, so an exclusion pattern means the same thing regardless of which inclusion patterns were given. It also avoids
aid:spuriously raising "needs to match precisely one archive ID" when the referenced archive had already been filtered out by an inclusion pattern.The option is defined in
define_archive_filters_group, so every command that already has-agets it, and it is passed through the singlelist_consideringfunnel.prunereacheslist()directly rather than through that funnel, so it is wired explicitly.LegacyArchivesgets the same treatment, otherwiseborg transfer --exclude-archives …would silently ignore the option when the source is a borg 1.x repository.borg help match-archivesnow documents both directions.Tests
Four cases in
repo_list_cmd_test.py: exclusion on its own, several exclusion patterns ORing together, exclusion combined with--match-archives, and exclusion via a non-name selector (tags:) so the shared matcher path is covered rather than just name globs.What I could not run
Borg does not run on native Windows and I could not build the Cython extensions here, so I have not executed the test suite locally — I am relying on CI and will follow up on whatever it reports. What I did verify locally:
ruff checkpasses on all six changed files, andblack --check(24.8.0, as pinned in.pre-commit-config.yaml) reports them unchanged.I left
CHANGES.rstand the generated usage docs alone, following #10291 and the note in the contributor docs that usage docs are regenerated at release time. Happy to add a changelog entry if you would rather have it in the PR.