changeset 49348:0043c7aa3250

rust-dirstate: add `unionmatcher` to the allowed matchers `UnionMatcher` is now implemented in Rust.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 08 Jun 2022 15:39:14 +0200
parents b508cffd3c04
children 5e53ecbc308f
files mercurial/dirstate.py rust/hg-cpython/src/dirstate/status.rs
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Wed Jun 08 11:55:40 2022 +0200
+++ b/mercurial/dirstate.py	Wed Jun 08 15:39:14 2022 +0200
@@ -1247,6 +1247,7 @@
             matchmod.alwaysmatcher,
             matchmod.exactmatcher,
             matchmod.includematcher,
+            matchmod.unionmatcher,
         )
 
         if rustmod is None:
--- a/rust/hg-cpython/src/dirstate/status.rs	Wed Jun 08 11:55:40 2022 +0200
+++ b/rust/hg-cpython/src/dirstate/status.rs	Wed Jun 08 15:39:14 2022 +0200
@@ -15,7 +15,7 @@
     PyResult, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::dirstate::status::StatusPath;
-use hg::matchers::Matcher;
+use hg::matchers::{Matcher, UnionMatcher};
 use hg::{
     matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher},
     parse_pattern_syntax,
@@ -217,6 +217,15 @@
 
             Ok(Box::new(matcher))
         }
+        "unionmatcher" => {
+            let matchers: PyResult<Vec<_>> = matcher
+                .getattr(py, "_matchers")?
+                .iter(py)?
+                .map(|py_matcher| extract_matcher(py, py_matcher?))
+                .collect();
+
+            Ok(Box::new(UnionMatcher::new(matchers?)))
+        }
         e => Err(PyErr::new::<FallbackError, _>(
             py,
             format!("Unsupported matcher {}", e),