changeset 49479:6193e846cb65

rust-status: expose DifferenceMatcher from Rust to Python
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 06 Jul 2022 11:46:00 +0200
parents d8ce883ff1f4
children 0199712c7a6d
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 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),