125 .collect(); |
125 .collect(); |
126 let ignore_files = ignore_files?; |
126 let ignore_files = ignore_files?; |
127 // The caller may call `copymap.items()` separately |
127 // The caller may call `copymap.items()` separately |
128 let list_copies = false; |
128 let list_copies = false; |
129 |
129 |
|
130 let after_status = |res: Result<(DirstateStatus<'_>, _), StatusError>| { |
|
131 let (status_res, warnings) = |
|
132 res.map_err(|e| handle_fallback(py, e))?; |
|
133 build_response(py, status_res, warnings) |
|
134 }; |
|
135 |
130 match matcher.get_type(py).name(py).borrow() { |
136 match matcher.get_type(py).name(py).borrow() { |
131 "alwaysmatcher" => { |
137 "alwaysmatcher" => { |
132 let matcher = AlwaysMatcher; |
138 let matcher = AlwaysMatcher; |
133 let (status_res, warnings) = dmap |
139 dmap.with_status( |
134 .status( |
140 &matcher, |
135 &matcher, |
141 root_dir.to_path_buf(), |
136 root_dir.to_path_buf(), |
142 ignore_files, |
137 ignore_files, |
143 StatusOptions { |
138 StatusOptions { |
144 check_exec, |
139 check_exec, |
145 list_clean, |
140 list_clean, |
146 list_ignored, |
141 list_ignored, |
147 list_unknown, |
142 list_unknown, |
148 list_copies, |
143 list_copies, |
149 collect_traversed_dirs, |
144 collect_traversed_dirs, |
150 }, |
145 }, |
151 after_status, |
146 ) |
152 ) |
147 .map_err(|e| handle_fallback(py, e))?; |
|
148 build_response(py, status_res, warnings) |
|
149 } |
153 } |
150 "exactmatcher" => { |
154 "exactmatcher" => { |
151 let files = matcher.call_method( |
155 let files = matcher.call_method( |
152 py, |
156 py, |
153 "files", |
157 "files", |
165 .collect(); |
169 .collect(); |
166 |
170 |
167 let files = files?; |
171 let files = files?; |
168 let matcher = FileMatcher::new(files.as_ref()) |
172 let matcher = FileMatcher::new(files.as_ref()) |
169 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?; |
173 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?; |
170 let (status_res, warnings) = dmap |
174 dmap.with_status( |
171 .status( |
175 &matcher, |
172 &matcher, |
176 root_dir.to_path_buf(), |
173 root_dir.to_path_buf(), |
177 ignore_files, |
174 ignore_files, |
178 StatusOptions { |
175 StatusOptions { |
179 check_exec, |
176 check_exec, |
180 list_clean, |
177 list_clean, |
181 list_ignored, |
178 list_ignored, |
182 list_unknown, |
179 list_unknown, |
183 list_copies, |
180 list_copies, |
184 collect_traversed_dirs, |
181 collect_traversed_dirs, |
185 }, |
182 }, |
186 after_status, |
183 ) |
187 ) |
184 .map_err(|e| handle_fallback(py, e))?; |
|
185 build_response(py, status_res, warnings) |
|
186 } |
188 } |
187 "includematcher" => { |
189 "includematcher" => { |
188 // Get the patterns from Python even though most of them are |
190 // Get the patterns from Python even though most of them are |
189 // redundant with those we will parse later on, as they include |
191 // redundant with those we will parse later on, as they include |
190 // those passed from the command line. |
192 // those passed from the command line. |
217 let ignore_patterns = ignore_patterns?; |
219 let ignore_patterns = ignore_patterns?; |
218 |
220 |
219 let matcher = IncludeMatcher::new(ignore_patterns) |
221 let matcher = IncludeMatcher::new(ignore_patterns) |
220 .map_err(|e| handle_fallback(py, e.into()))?; |
222 .map_err(|e| handle_fallback(py, e.into()))?; |
221 |
223 |
222 let (status_res, warnings) = dmap |
224 dmap.with_status( |
223 .status( |
225 &matcher, |
224 &matcher, |
226 root_dir.to_path_buf(), |
225 root_dir.to_path_buf(), |
227 ignore_files, |
226 ignore_files, |
228 StatusOptions { |
227 StatusOptions { |
229 check_exec, |
228 check_exec, |
230 list_clean, |
229 list_clean, |
231 list_ignored, |
230 list_ignored, |
232 list_unknown, |
231 list_unknown, |
233 list_copies, |
232 list_copies, |
234 collect_traversed_dirs, |
233 collect_traversed_dirs, |
235 }, |
234 }, |
236 after_status, |
235 ) |
237 ) |
236 .map_err(|e| handle_fallback(py, e))?; |
|
237 |
|
238 build_response(py, status_res, warnings) |
|
239 } |
238 } |
240 e => Err(PyErr::new::<ValueError, _>( |
239 e => Err(PyErr::new::<ValueError, _>( |
241 py, |
240 py, |
242 format!("Unsupported matcher {}", e), |
241 format!("Unsupported matcher {}", e), |
243 )), |
242 )), |