changeset 49351:97dcd6906e6f

rust-dirstate: add support for nevermatcher This is in case this ever comes up, it's very easy to support, so might as well do it.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 08 Jun 2022 18:18:19 +0200
parents 0b00998e336a
children fa8d974284f8
files mercurial/dirstate.py rust/hg-core/src/matchers.rs rust/hg-cpython/src/dirstate/status.rs
diffstat 3 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Wed Jun 08 18:12:55 2022 +0200
+++ b/mercurial/dirstate.py	Wed Jun 08 18:18:19 2022 +0200
@@ -1248,6 +1248,7 @@
             matchmod.exactmatcher,
             matchmod.includematcher,
             matchmod.intersectionmatcher,
+            matchmod.nevermatcher,
             matchmod.unionmatcher,
         )
 
--- a/rust/hg-core/src/matchers.rs	Wed Jun 08 18:12:55 2022 +0200
+++ b/rust/hg-core/src/matchers.rs	Wed Jun 08 18:18:19 2022 +0200
@@ -134,6 +134,31 @@
     }
 }
 
+/// Matches nothing.
+#[derive(Debug)]
+pub struct NeverMatcher;
+
+impl Matcher for NeverMatcher {
+    fn file_set(&self) -> Option<&HashSet<HgPathBuf>> {
+        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.
 ///
--- a/rust/hg-cpython/src/dirstate/status.rs	Wed Jun 08 18:12:55 2022 +0200
+++ b/rust/hg-cpython/src/dirstate/status.rs	Wed Jun 08 18:18:19 2022 +0200
@@ -15,7 +15,7 @@
     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 @@
 ) -> PyResult<Box<dyn Matcher + Sync>> {
     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,