Skip to content

manifest: allow comma-separated archive IDs in aid: matcher (#10313) - #10653

Open
Siddharth-Dangi wants to merge 1 commit into
borgbackup:masterfrom
Siddharth-Dangi:feat/aid-comma-separated
Open

Siddharth-Dangi wants to merge 1 commit into
borgbackup:masterfrom
Siddharth-Dangi:feat/aid-comma-separated

Conversation

@Siddharth-Dangi

Copy link
Copy Markdown

Fixes #10313

Summary

  • Update aid: archive matching in Archives._matching_info_tuples (src/borg/manifest.py and src/borg/legacy/archives.py) to accept comma-separated archive ID prefixes with OR semantics (e.g. aid:ID1,ID2).
  • Enforce that each non-empty ID prefix matches precisely one archive (raising CommandError on empty, missing, or ambiguous prefixes).
  • Preserve existing archive_infos ordering and deduplicate overlapping prefixes via matched_ids.
  • Update borg help match-archives (src/borg/archiver/help_cmd.py) to document comma-separated aid: lists.

Testing

  • Added unit tests in src/borg/testsuite/archives_test.py (test_list_match_aid_multiple, test_list_match_aid_multiple_dedup, test_list_match_aid_multiple_error) and src/borg/testsuite/legacy_archives_test.py (test_list_match_aid_multiple).
  • Verified test_list_match* (22 passed) and ruff check locally.

…up#10313)

Signed-off-by: Siddharth-Dangi <mr.siddharthdangi@gmail.com>

@ThomasWaldmann ThomasWaldmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good overall - tests pass and repo-list -a aid:A,B works as expected in a quick manual test.

Two requests:

  1. Error message: with a list of IDs, archive ID based match needs to match precisely one archive ID no longer tells the user which ID failed or whether it matched no or multiple archives, so with aid:A,B,C,D one has to bisect. If easily doable, please include the offending prefix and the match count, e.g.:

    raise CommandError(f"aid:{wanted_id} matched {len(matches)} archives, but needs to match precisely one archive")

    (in both manifest.py and legacy/archives.py; the tests use match=r"precisely one", so they would still work.)

  2. Help example: please also add an example for the new syntax to the examples section of borg help match-archives, next to the existing borg delete -a 'aid:d34db33f', e.g. borg delete -a 'aid:d34db33f,1ddaae55'.

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (06e0482) to head (c813cee).
⚠️ Report is 6 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/legacy/archives.py 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10653   +/-   ##
=======================================
  Coverage   89.47%   89.47%           
=======================================
  Files         105      105           
  Lines       20343    20355   +12     
  Branches     3199     3203    +4     
=======================================
+ Hits        18201    18212   +11     
+ Misses       1489     1487    -2     
- Partials      653      656    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

borg2: Allow comma-separated archive IDs in aid: matcher

2 participants