# HG changeset patch # User Spencer Baugh # Date 2023-08-02 13:57:29 # Node ID e037af7de2ce9bd0760add4666d4d022f6e8c75e # Parent b76a938cc9dd3b38389d2d7f965e2b8e56a3a2dc rust-matchers: better support file_set in IntersectionMatcher Previously, if both of the input matchers had non-exact file sets, IntersectionMatcher would simply have an empty fileset. Now, we duplicate Python behavior: we *union* the filesets of the matchers in that case. This makes some sense, because without exact input file sets, we can't do an exact intersection and must over-approximate. Concretely, this is necessary because the file_set is the list of files that were explicitly listed by the user, and we want to provide explicit errors for all such files, from both matchers. diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -479,7 +479,13 @@ impl IntersectionMatcher { m1_files.iter().cloned().filter(|f| m2.matches(f)).collect() }) } else { - None + // without exact input file sets, we can't do an exact + // intersection, so we must over-approximate by + // unioning instead + m1.file_set().map(|m1_files| match m2.file_set() { + Some(m2_files) => m1_files.union(m2_files).cloned().collect(), + None => m1_files.iter().cloned().collect(), + }) }; Self { m1, m2, files } }