15 exc::ValueError, ObjectProtocol, PyBytes, PyErr, PyList, PyObject, |
15 exc::ValueError, ObjectProtocol, PyBytes, PyErr, PyList, PyObject, |
16 PyResult, PyTuple, Python, PythonObject, ToPyObject, |
16 PyResult, PyTuple, Python, PythonObject, ToPyObject, |
17 }; |
17 }; |
18 use hg::{ |
18 use hg::{ |
19 matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher}, |
19 matchers::{AlwaysMatcher, FileMatcher, IncludeMatcher}, |
20 parse_pattern_syntax, status, |
20 parse_pattern_syntax, |
21 utils::{ |
21 utils::{ |
22 files::{get_bytes_from_path, get_path_from_bytes}, |
22 files::{get_bytes_from_path, get_path_from_bytes}, |
23 hg_path::{HgPath, HgPathBuf}, |
23 hg_path::{HgPath, HgPathBuf}, |
24 }, |
24 }, |
25 BadMatch, DirstateStatus, IgnorePattern, PatternFileWarning, StatusError, |
25 BadMatch, DirstateStatus, IgnorePattern, PatternFileWarning, StatusError, |
124 let ignore_files = ignore_files?; |
124 let ignore_files = ignore_files?; |
125 |
125 |
126 match matcher.get_type(py).name(py).borrow() { |
126 match matcher.get_type(py).name(py).borrow() { |
127 "alwaysmatcher" => { |
127 "alwaysmatcher" => { |
128 let matcher = AlwaysMatcher; |
128 let matcher = AlwaysMatcher; |
129 let ((lookup, status_res), warnings) = status( |
129 let ((lookup, status_res), warnings) = dmap |
130 &dmap, |
130 .status( |
131 &matcher, |
131 &matcher, |
132 root_dir.to_path_buf(), |
132 root_dir.to_path_buf(), |
133 ignore_files, |
133 ignore_files, |
134 StatusOptions { |
134 StatusOptions { |
135 check_exec, |
135 check_exec, |
136 last_normal_time, |
136 last_normal_time, |
137 list_clean, |
137 list_clean, |
138 list_ignored, |
138 list_ignored, |
139 list_unknown, |
139 list_unknown, |
140 collect_traversed_dirs, |
140 collect_traversed_dirs, |
141 }, |
141 }, |
142 ) |
142 ) |
143 .map_err(|e| handle_fallback(py, e))?; |
143 .map_err(|e| handle_fallback(py, e))?; |
144 build_response(py, lookup, status_res, warnings) |
144 build_response(py, lookup, status_res, warnings) |
145 } |
145 } |
146 "exactmatcher" => { |
146 "exactmatcher" => { |
147 let files = matcher.call_method( |
147 let files = matcher.call_method( |
148 py, |
148 py, |
161 .collect(); |
161 .collect(); |
162 |
162 |
163 let files = files?; |
163 let files = files?; |
164 let matcher = FileMatcher::new(files.as_ref()) |
164 let matcher = FileMatcher::new(files.as_ref()) |
165 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?; |
165 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?; |
166 let ((lookup, status_res), warnings) = status( |
166 let ((lookup, status_res), warnings) = dmap |
167 &dmap, |
167 .status( |
168 &matcher, |
168 &matcher, |
169 root_dir.to_path_buf(), |
169 root_dir.to_path_buf(), |
170 ignore_files, |
170 ignore_files, |
171 StatusOptions { |
171 StatusOptions { |
172 check_exec, |
172 check_exec, |
173 last_normal_time, |
173 last_normal_time, |
174 list_clean, |
174 list_clean, |
175 list_ignored, |
175 list_ignored, |
176 list_unknown, |
176 list_unknown, |
177 collect_traversed_dirs, |
177 collect_traversed_dirs, |
178 }, |
178 }, |
179 ) |
179 ) |
180 .map_err(|e| handle_fallback(py, e))?; |
180 .map_err(|e| handle_fallback(py, e))?; |
181 build_response(py, lookup, status_res, warnings) |
181 build_response(py, lookup, status_res, warnings) |
182 } |
182 } |
183 "includematcher" => { |
183 "includematcher" => { |
184 // Get the patterns from Python even though most of them are |
184 // Get the patterns from Python even though most of them are |
185 // redundant with those we will parse later on, as they include |
185 // redundant with those we will parse later on, as they include |
216 let (matcher, warnings) = |
216 let (matcher, warnings) = |
217 IncludeMatcher::new(ignore_patterns, &root_dir) |
217 IncludeMatcher::new(ignore_patterns, &root_dir) |
218 .map_err(|e| handle_fallback(py, e.into()))?; |
218 .map_err(|e| handle_fallback(py, e.into()))?; |
219 all_warnings.extend(warnings); |
219 all_warnings.extend(warnings); |
220 |
220 |
221 let ((lookup, status_res), warnings) = status( |
221 let ((lookup, status_res), warnings) = dmap |
222 &dmap, |
222 .status( |
223 &matcher, |
223 &matcher, |
224 root_dir.to_path_buf(), |
224 root_dir.to_path_buf(), |
225 ignore_files, |
225 ignore_files, |
226 StatusOptions { |
226 StatusOptions { |
227 check_exec, |
227 check_exec, |
228 last_normal_time, |
228 last_normal_time, |
229 list_clean, |
229 list_clean, |
230 list_ignored, |
230 list_ignored, |
231 list_unknown, |
231 list_unknown, |
232 collect_traversed_dirs, |
232 collect_traversed_dirs, |
233 }, |
233 }, |
234 ) |
234 ) |
235 .map_err(|e| handle_fallback(py, e))?; |
235 .map_err(|e| handle_fallback(py, e))?; |
236 |
236 |
237 all_warnings.extend(warnings); |
237 all_warnings.extend(warnings); |
238 |
238 |
239 build_response(py, lookup, status_res, all_warnings) |
239 build_response(py, lookup, status_res, all_warnings) |
240 } |
240 } |