Show More
@@ -11,7 +11,7 b'' | |||||
11 |
|
11 | |||
12 | use crate::{dirstate::DirstateMap, exceptions::FallbackError}; |
|
12 | use crate::{dirstate::DirstateMap, exceptions::FallbackError}; | |
13 | use cpython::{ |
|
13 | use cpython::{ | |
14 | exc::ValueError, ObjectProtocol, PyBytes, PyErr, PyList, PyObject, |
|
14 | exc::ValueError, ObjectProtocol, PyBool, PyBytes, PyErr, PyList, PyObject, | |
15 | PyResult, PyTuple, Python, PythonObject, ToPyObject, |
|
15 | PyResult, PyTuple, Python, PythonObject, ToPyObject, | |
16 | }; |
|
16 | }; | |
17 | use hg::dirstate::status::StatusPath; |
|
17 | use hg::dirstate::status::StatusPath; | |
@@ -26,8 +26,8 b' use hg::{' | |||||
26 | files::{get_bytes_from_path, get_path_from_bytes}, |
|
26 | files::{get_bytes_from_path, get_path_from_bytes}, | |
27 | hg_path::{HgPath, HgPathBuf}, |
|
27 | hg_path::{HgPath, HgPathBuf}, | |
28 | }, |
|
28 | }, | |
29 |
BadMatch, DirstateStatus, IgnorePattern, PatternFileWarning, |
|
29 | BadMatch, DirstateStatus, IgnorePattern, PatternError, PatternFileWarning, | |
30 | StatusOptions, |
|
30 | StatusError, StatusOptions, | |
31 | }; |
|
31 | }; | |
32 | use std::borrow::Borrow; |
|
32 | use std::borrow::Borrow; | |
33 |
|
33 | |||
@@ -158,6 +158,18 b' fn extract_matcher(' | |||||
158 | py: Python, |
|
158 | py: Python, | |
159 | matcher: PyObject, |
|
159 | matcher: PyObject, | |
160 | ) -> PyResult<Box<dyn Matcher + Sync>> { |
|
160 | ) -> PyResult<Box<dyn Matcher + Sync>> { | |
|
161 | let tampered = matcher | |||
|
162 | .call_method(py, "was_tampered_with", PyTuple::empty(py), None)? | |||
|
163 | .extract::<PyBool>(py)? | |||
|
164 | .is_true(); | |||
|
165 | if tampered { | |||
|
166 | return Err(handle_fallback( | |||
|
167 | py, | |||
|
168 | StatusError::Pattern(PatternError::UnsupportedSyntax( | |||
|
169 | "Pattern matcher was tampered with!".to_string(), | |||
|
170 | )), | |||
|
171 | )); | |||
|
172 | }; | |||
161 | match matcher.get_type(py).name(py).borrow() { |
|
173 | match matcher.get_type(py).name(py).borrow() { | |
162 | "alwaysmatcher" => Ok(Box::new(AlwaysMatcher)), |
|
174 | "alwaysmatcher" => Ok(Box::new(AlwaysMatcher)), | |
163 | "nevermatcher" => Ok(Box::new(NeverMatcher)), |
|
175 | "nevermatcher" => Ok(Box::new(NeverMatcher)), |
General Comments 0
You need to be logged in to leave comments.
Login now