Mercurial > hg
changeset 50856:e037af7de2ce
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.
author | Spencer Baugh <sbaugh@janestreet.com> |
---|---|
date | Wed, 02 Aug 2023 09:57:29 -0400 |
parents | b76a938cc9dd |
children | 796b5d6693a4 |
files | rust/hg-core/src/matchers.rs |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/matchers.rs Mon Aug 21 10:00:08 2023 +0200 +++ b/rust/hg-core/src/matchers.rs Wed Aug 02 09:57:29 2023 -0400 @@ -479,7 +479,13 @@ 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 } }