# HG changeset patch # User Raphaël Gomès # Date 2022-07-06 09:46:00 # Node ID 6193e846cb65300ad830a0e95ec65375a1194ff1 # Parent d8ce883ff1f4509c10ce5505313b070e68acb206 rust-status: expose DifferenceMatcher from Rust to Python diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1287,6 +1287,7 @@ class dirstate: allowed_matchers = ( matchmod.alwaysmatcher, + matchmod.differencematcher, matchmod.exactmatcher, matchmod.includematcher, matchmod.intersectionmatcher, 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,10 @@ use cpython::{ PyResult, PyTuple, Python, PythonObject, ToPyObject, }; use hg::dirstate::status::StatusPath; -use hg::matchers::{IntersectionMatcher, Matcher, NeverMatcher, UnionMatcher}; +use hg::matchers::{ + DifferenceMatcher, IntersectionMatcher, Matcher, NeverMatcher, + UnionMatcher, +}; use hg::{ matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher}, parse_pattern_syntax, @@ -233,6 +236,12 @@ fn extract_matcher( Ok(Box::new(IntersectionMatcher::new(m1, m2))) } + "differencematcher" => { + let m1 = extract_matcher(py, matcher.getattr(py, "_m1")?)?; + let m2 = extract_matcher(py, matcher.getattr(py, "_m2")?)?; + + Ok(Box::new(DifferenceMatcher::new(m1, m2))) + } e => Err(PyErr::new::( py, format!("Unsupported matcher {}", e),