rust-status: expose DifferenceMatcher from Rust to Python
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 06 Jul 2022 11:46:00 +0200
changeset 49479 6193e846cb65
parent 49478 d8ce883ff1f4
child 49480 0199712c7a6d
rust-status: expose DifferenceMatcher from Rust to Python
mercurial/dirstate.py
rust/hg-cpython/src/dirstate/status.rs
--- a/mercurial/dirstate.py	Wed Jul 06 11:44:20 2022 +0200
+++ b/mercurial/dirstate.py	Wed Jul 06 11:46:00 2022 +0200
@@ -1287,6 +1287,7 @@
 
         allowed_matchers = (
             matchmod.alwaysmatcher,
+            matchmod.differencematcher,
             matchmod.exactmatcher,
             matchmod.includematcher,
             matchmod.intersectionmatcher,
--- a/rust/hg-cpython/src/dirstate/status.rs	Wed Jul 06 11:44:20 2022 +0200
+++ b/rust/hg-cpython/src/dirstate/status.rs	Wed Jul 06 11:46:00 2022 +0200
@@ -15,7 +15,10 @@
     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 @@
 
             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::<FallbackError, _>(
             py,
             format!("Unsupported matcher {}", e),