# HG changeset patch # User Raphaël Gomès # Date 2022-06-08 13:39:14 # Node ID 0043c7aa3250af867b40d0d2f515f07672fbacb7 # Parent b508cffd3c04fdd5d493a73548eaf60053a51872 rust-dirstate: add `unionmatcher` to the allowed matchers `UnionMatcher` is now implemented in Rust. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1247,6 +1247,7 @@ class dirstate: matchmod.alwaysmatcher, matchmod.exactmatcher, matchmod.includematcher, + matchmod.unionmatcher, ) if rustmod is None: 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; +use hg::matchers::{Matcher, UnionMatcher}; use hg::{ matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher}, parse_pattern_syntax, @@ -217,6 +217,15 @@ fn extract_matcher( Ok(Box::new(matcher)) } + "unionmatcher" => { + let matchers: PyResult> = 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::( py, format!("Unsupported matcher {}", e),