diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1248,6 +1248,7 @@ class dirstate: matchmod.exactmatcher, matchmod.includematcher, matchmod.intersectionmatcher, + matchmod.nevermatcher, matchmod.unionmatcher, ) 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 @@ -134,6 +134,31 @@ impl Matcher for AlwaysMatcher { } } +/// Matches nothing. +#[derive(Debug)] +pub struct NeverMatcher; + +impl Matcher for NeverMatcher { + fn file_set(&self) -> Option<&HashSet> { + None + } + fn exact_match(&self, _filename: &HgPath) -> bool { + false + } + fn matches(&self, _filename: &HgPath) -> bool { + false + } + fn visit_children_set(&self, _directory: &HgPath) -> VisitChildrenSet { + VisitChildrenSet::Empty + } + fn matches_everything(&self) -> bool { + false + } + fn is_exact(&self) -> bool { + true + } +} + /// Matches the input files exactly. They are interpreted as paths, not /// patterns. /// diff --git a/rust/hg-cpython/src/dirstate/status.rs b/rust/hg-cpython/src/dirstate/status.rs --- a/rust/hg-cpython/src/dirstate/status.rs +++ b/rust/hg-cpython/src/dirstate/status.rs @@ -15,7 +15,7 @@ use cpython::{ PyResult, PyTuple, Python, PythonObject, ToPyObject, }; use hg::dirstate::status::StatusPath; -use hg::matchers::{Matcher, UnionMatcher, IntersectionMatcher}; +use hg::matchers::{IntersectionMatcher, Matcher, NeverMatcher, UnionMatcher}; use hg::{ matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher}, parse_pattern_syntax, @@ -158,6 +158,7 @@ fn extract_matcher( ) -> PyResult> { match matcher.get_type(py).name(py).borrow() { "alwaysmatcher" => Ok(Box::new(AlwaysMatcher)), + "nevermatcher" => Ok(Box::new(NeverMatcher)), "exactmatcher" => { let files = matcher.call_method( py,