Skip to content

feat: add FilterChain for per-directory merge filter scoping - #3033

Merged
oferchen merged 2 commits into
masterfrom
feature/per-dir-merge-filters
Mar 28, 2026
Merged

oferchen merged 2 commits into
masterfrom
feature/per-dir-merge-filters

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds FilterChain type to the filters crate, implementing upstream rsync's per-directory merge filter push/pop semantics from exclude.c:push_local_filters()/pop_local_filters()
  • Adds DirMergeConfig for configuring per-directory merge file behavior (filename, inherit, exclude-self, sender/receiver-only, anchor-root, perishable modifiers)
  • Adds DirFilterGuard for tracking pushed scopes and FilterChainError for error handling
  • Evaluates paths from innermost directory scope outward to global rules with first-match-wins semantics

Test plan

  • Unit tests for DirMergeConfig construction and modifier application
  • Tests for FilterChain basic operations (empty, global rules, deletion)
  • Tests for scope push/pop with push_scope/leave_directory
  • Tests for nested directory scopes (inner overrides outer)
  • Tests for merge file reading from disk (via enter_directory)
  • Tests for missing/empty/comments-only merge files (graceful handling)
  • Tests for exclude_self modifier
  • Tests for include+exclude rules in merge files
  • Tests for nested directories with merge files
  • Tests for multiple merge configs
  • Tests for parse errors in merge files
  • Tests for protect rules in per-directory scopes
  • Tests for global rules persisting across scope push/pop
  • Tests for FilterChainError display and source
  • All 1181 filters crate tests pass
  • Clippy clean with -D warnings
  • Rustdoc builds without broken links

Implement FilterChain in the filters crate, providing a scoped
filter evaluation stack that mirrors upstream rsync's
push_local_filters()/pop_local_filters() from exclude.c.

Key components:
- FilterChain: manages global FilterSet + per-directory scope stack
- DirMergeConfig: configures merge file behavior (inherit, exclude-self,
  sender/receiver-only, anchor-root, perishable modifiers)
- DirFilterGuard: tracks pushed scopes for leave_directory() cleanup
- FilterChainError: covers I/O, parse, and compilation failures

The chain evaluates paths from innermost scope outward to global rules,
with first-match-wins semantics at each layer. Missing merge files are
silently skipped, matching upstream behavior.

Includes comprehensive tests for: scope push/pop, nested directories,
merge file reading, empty/missing files, modifier application, multiple
merge configs, parse errors, protect rules, and guard lifetime.
@github-actions github-actions Bot added the enhancement New feature or request label Mar 28, 2026
@oferchen
oferchen merged commit 9dfea88 into master Mar 28, 2026
34 checks passed
@oferchen
oferchen deleted the feature/per-dir-merge-filters branch March 28, 2026 13:49
oferchen added a commit that referenced this pull request May 1, 2026
* feat: add FilterChain for per-directory merge filter scoping

Implement FilterChain in the filters crate, providing a scoped
filter evaluation stack that mirrors upstream rsync's
push_local_filters()/pop_local_filters() from exclude.c.

Key components:
- FilterChain: manages global FilterSet + per-directory scope stack
- DirMergeConfig: configures merge file behavior (inherit, exclude-self,
  sender/receiver-only, anchor-root, perishable modifiers)
- DirFilterGuard: tracks pushed scopes for leave_directory() cleanup
- FilterChainError: covers I/O, parse, and compilation failures

The chain evaluates paths from innermost scope outward to global rules,
with first-match-wins semantics at each layer. Missing merge files are
silently skipped, matching upstream behavior.

Includes comprehensive tests for: scope push/pop, nested directories,
merge file reading, empty/missing files, modifier application, multiple
merge configs, parse errors, protect rules, and guard lifetime.

* style: fix rustfmt multi-line if conditions in FilterChain
oferchen added a commit that referenced this pull request May 5, 2026
* feat: add FilterChain for per-directory merge filter scoping

Implement FilterChain in the filters crate, providing a scoped
filter evaluation stack that mirrors upstream rsync's
push_local_filters()/pop_local_filters() from exclude.c.

Key components:
- FilterChain: manages global FilterSet + per-directory scope stack
- DirMergeConfig: configures merge file behavior (inherit, exclude-self,
  sender/receiver-only, anchor-root, perishable modifiers)
- DirFilterGuard: tracks pushed scopes for leave_directory() cleanup
- FilterChainError: covers I/O, parse, and compilation failures

The chain evaluates paths from innermost scope outward to global rules,
with first-match-wins semantics at each layer. Missing merge files are
silently skipped, matching upstream behavior.

Includes comprehensive tests for: scope push/pop, nested directories,
merge file reading, empty/missing files, modifier application, multiple
merge configs, parse errors, protect rules, and guard lifetime.

* style: fix rustfmt multi-line if conditions in FilterChain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant