##// END OF EJS Templates
rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct...
Simon Sapin -
r47880:9c6b458a default
parent child Browse files
Show More
@@ -264,6 +264,10 b" pub struct DirstateStatus<'a> {"
264 264 pub ignored: Vec<HgPathCow<'a>>,
265 265 pub unknown: Vec<HgPathCow<'a>>,
266 266 pub bad: Vec<(HgPathCow<'a>, BadMatch)>,
267 /// Either clean or modified, but we can’t tell from filesystem metadata
268 /// alone. The file contents need to be read and compared with that in
269 /// the parent.
270 pub unsure: Vec<HgPathCow<'a>>,
267 271 /// Only filled if `collect_traversed_dirs` is `true`
268 272 pub traversed: Vec<HgPathBuf>,
269 273 }
@@ -847,8 +851,8 b' where'
847 851 pub fn build_response<'a>(
848 852 results: impl IntoIterator<Item = DispatchedPath<'a>>,
849 853 traversed: Vec<HgPathBuf>,
850 ) -> (Vec<HgPathCow<'a>>, DirstateStatus<'a>) {
851 let mut lookup = vec![];
854 ) -> DirstateStatus<'a> {
855 let mut unsure = vec![];
852 856 let mut modified = vec![];
853 857 let mut added = vec![];
854 858 let mut removed = vec![];
@@ -861,7 +865,7 b" pub fn build_response<'a>("
861 865 for (filename, dispatch) in results.into_iter() {
862 866 match dispatch {
863 867 Dispatch::Unknown => unknown.push(filename),
864 Dispatch::Unsure => lookup.push(filename),
868 Dispatch::Unsure => unsure.push(filename),
865 869 Dispatch::Modified => modified.push(filename),
866 870 Dispatch::Added => added.push(filename),
867 871 Dispatch::Removed => removed.push(filename),
@@ -874,20 +878,18 b" pub fn build_response<'a>("
874 878 }
875 879 }
876 880
877 (
878 lookup,
879 DirstateStatus {
880 modified,
881 added,
882 removed,
883 deleted,
884 clean,
885 ignored,
886 unknown,
887 bad,
888 traversed,
889 },
890 )
881 DirstateStatus {
882 modified,
883 added,
884 removed,
885 deleted,
886 clean,
887 ignored,
888 unknown,
889 bad,
890 unsure,
891 traversed,
892 }
891 893 }
892 894
893 895 /// Get the status of files in the working directory.
@@ -902,10 +904,7 b" pub fn status<'a>("
902 904 root_dir: PathBuf,
903 905 ignore_files: Vec<PathBuf>,
904 906 options: StatusOptions,
905 ) -> StatusResult<(
906 (Vec<HgPathCow<'a>>, DirstateStatus<'a>),
907 Vec<PatternFileWarning>,
908 )> {
907 ) -> StatusResult<(DirstateStatus<'a>, Vec<PatternFileWarning>)> {
909 908 let (status, warnings) =
910 909 Status::new(dmap, matcher, root_dir, ignore_files, options)?;
911 910
@@ -19,7 +19,6 b' use crate::DirstateMapError;'
19 19 use crate::DirstateParents;
20 20 use crate::DirstateStatus;
21 21 use crate::EntryState;
22 use crate::HgPathCow;
23 22 use crate::PatternFileWarning;
24 23 use crate::StateMapIter;
25 24 use crate::StatusError;
@@ -582,13 +581,8 b' impl super::dispatch::DirstateMapMethods'
582 581 _root_dir: PathBuf,
583 582 _ignore_files: Vec<PathBuf>,
584 583 _options: StatusOptions,
585 ) -> Result<
586 (
587 (Vec<HgPathCow<'a>>, DirstateStatus<'a>),
588 Vec<PatternFileWarning>,
589 ),
590 StatusError,
591 > {
584 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>
585 {
592 586 todo!()
593 587 }
594 588
@@ -11,7 +11,6 b' use crate::DirstateMapError;'
11 11 use crate::DirstateParents;
12 12 use crate::DirstateStatus;
13 13 use crate::EntryState;
14 use crate::HgPathCow;
15 14 use crate::PatternFileWarning;
16 15 use crate::StateMapIter;
17 16 use crate::StatusError;
@@ -102,13 +101,7 b' pub trait DirstateMapMethods {'
102 101 root_dir: PathBuf,
103 102 ignore_files: Vec<PathBuf>,
104 103 options: StatusOptions,
105 ) -> Result<
106 (
107 (Vec<HgPathCow<'a>>, DirstateStatus<'a>),
108 Vec<PatternFileWarning>,
109 ),
110 StatusError,
111 >;
104 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>;
112 105
113 106 fn copy_map_len(&self) -> usize;
114 107
@@ -270,13 +263,8 b' impl DirstateMapMethods for DirstateMap '
270 263 root_dir: PathBuf,
271 264 ignore_files: Vec<PathBuf>,
272 265 options: StatusOptions,
273 ) -> Result<
274 (
275 (Vec<HgPathCow<'a>>, DirstateStatus<'a>),
276 Vec<PatternFileWarning>,
277 ),
278 StatusError,
279 > {
266 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>
267 {
280 268 crate::status(self, matcher, root_dir, ignore_files, options)
281 269 }
282 270
@@ -5,17 +5,12 b''
5 5 // This software may be used and distributed according to the terms of the
6 6 // GNU General Public License version 2 or any later version.
7 7
8 use crate::dirstate::status::{build_response, Dispatch, HgPathCow, Status};
8 use crate::dirstate::status::{build_response, Dispatch, Status};
9 9 use crate::matchers::Matcher;
10 10 use crate::{DirstateStatus, StatusError};
11 11
12 /// A tuple of the paths that need to be checked in the filelog because it's
13 /// ambiguous whether they've changed, and the rest of the already dispatched
14 /// files.
15 pub type LookupAndStatus<'a> = (Vec<HgPathCow<'a>>, DirstateStatus<'a>);
16
17 12 impl<'a, M: ?Sized + Matcher + Sync> Status<'a, M> {
18 pub(crate) fn run(&self) -> Result<LookupAndStatus<'a>, StatusError> {
13 pub(crate) fn run(&self) -> Result<DirstateStatus<'a>, StatusError> {
19 14 let (traversed_sender, traversed_receiver) =
20 15 crossbeam_channel::unbounded();
21 16
@@ -25,7 +25,7 b' use hg::{'
25 25 BadMatch, DirstateStatus, IgnorePattern, PatternFileWarning, StatusError,
26 26 StatusOptions,
27 27 };
28 use std::borrow::{Borrow, Cow};
28 use std::borrow::Borrow;
29 29
30 30 /// This will be useless once trait impls for collection are added to `PyBytes`
31 31 /// upstream.
@@ -126,7 +126,7 b' pub fn status_wrapper('
126 126 match matcher.get_type(py).name(py).borrow() {
127 127 "alwaysmatcher" => {
128 128 let matcher = AlwaysMatcher;
129 let ((lookup, status_res), warnings) = dmap
129 let (status_res, warnings) = dmap
130 130 .status(
131 131 &matcher,
132 132 root_dir.to_path_buf(),
@@ -141,7 +141,7 b' pub fn status_wrapper('
141 141 },
142 142 )
143 143 .map_err(|e| handle_fallback(py, e))?;
144 build_response(py, lookup, status_res, warnings)
144 build_response(py, status_res, warnings)
145 145 }
146 146 "exactmatcher" => {
147 147 let files = matcher.call_method(
@@ -163,7 +163,7 b' pub fn status_wrapper('
163 163 let files = files?;
164 164 let matcher = FileMatcher::new(files.as_ref())
165 165 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?;
166 let ((lookup, status_res), warnings) = dmap
166 let (status_res, warnings) = dmap
167 167 .status(
168 168 &matcher,
169 169 root_dir.to_path_buf(),
@@ -178,7 +178,7 b' pub fn status_wrapper('
178 178 },
179 179 )
180 180 .map_err(|e| handle_fallback(py, e))?;
181 build_response(py, lookup, status_res, warnings)
181 build_response(py, status_res, warnings)
182 182 }
183 183 "includematcher" => {
184 184 // Get the patterns from Python even though most of them are
@@ -218,7 +218,7 b' pub fn status_wrapper('
218 218 .map_err(|e| handle_fallback(py, e.into()))?;
219 219 all_warnings.extend(warnings);
220 220
221 let ((lookup, status_res), warnings) = dmap
221 let (status_res, warnings) = dmap
222 222 .status(
223 223 &matcher,
224 224 root_dir.to_path_buf(),
@@ -236,7 +236,7 b' pub fn status_wrapper('
236 236
237 237 all_warnings.extend(warnings);
238 238
239 build_response(py, lookup, status_res, all_warnings)
239 build_response(py, status_res, all_warnings)
240 240 }
241 241 e => Err(PyErr::new::<ValueError, _>(
242 242 py,
@@ -247,7 +247,6 b' pub fn status_wrapper('
247 247
248 248 fn build_response(
249 249 py: Python,
250 lookup: Vec<Cow<HgPath>>,
251 250 status_res: DirstateStatus,
252 251 warnings: Vec<PatternFileWarning>,
253 252 ) -> PyResult<PyTuple> {
@@ -258,7 +257,7 b' fn build_response('
258 257 let clean = collect_pybytes_list(py, status_res.clean.as_ref());
259 258 let ignored = collect_pybytes_list(py, status_res.ignored.as_ref());
260 259 let unknown = collect_pybytes_list(py, status_res.unknown.as_ref());
261 let lookup = collect_pybytes_list(py, lookup.as_ref());
260 let unsure = collect_pybytes_list(py, status_res.unsure.as_ref());
262 261 let bad = collect_bad_matches(py, status_res.bad.as_ref())?;
263 262 let traversed = collect_pybytes_list(py, status_res.traversed.as_ref());
264 263 let py_warnings = PyList::new(py, &[]);
@@ -287,7 +286,7 b' fn build_response('
287 286 Ok(PyTuple::new(
288 287 py,
289 288 &[
290 lookup.into_object(),
289 unsure.into_object(),
291 290 modified.into_object(),
292 291 added.into_object(),
293 292 removed.into_object(),
@@ -181,7 +181,7 b' pub fn run(invocation: &crate::CliInvoca'
181 181 collect_traversed_dirs: false,
182 182 };
183 183 let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded
184 let ((lookup, ds_status), pattern_warnings) = hg::status(
184 let (ds_status, pattern_warnings) = hg::status(
185 185 &dmap,
186 186 &AlwaysMatcher,
187 187 repo.working_directory_path().to_owned(),
@@ -195,10 +195,10 b' pub fn run(invocation: &crate::CliInvoca'
195 195 if !ds_status.bad.is_empty() {
196 196 warn!("Bad matches {:?}", &(ds_status.bad))
197 197 }
198 if !lookup.is_empty() {
198 if !ds_status.unsure.is_empty() {
199 199 info!(
200 200 "Files to be rechecked by retrieval from filelog: {:?}",
201 &lookup
201 &ds_status.unsure
202 202 );
203 203 }
204 204 // TODO check ordering to match `hg status` output.
@@ -206,7 +206,7 b' pub fn run(invocation: &crate::CliInvoca'
206 206 if display_states.modified {
207 207 display_status_paths(ui, &(ds_status.modified), b"M")?;
208 208 }
209 if !lookup.is_empty() {
209 if !ds_status.unsure.is_empty() {
210 210 let p1: Node = parents
211 211 .expect(
212 212 "Dirstate with no parents should not list any file to
@@ -217,7 +217,7 b' pub fn run(invocation: &crate::CliInvoca'
217 217 let p1_hex = format!("{:x}", p1);
218 218 let mut rechecked_modified: Vec<HgPathCow> = Vec::new();
219 219 let mut rechecked_clean: Vec<HgPathCow> = Vec::new();
220 for to_check in lookup {
220 for to_check in ds_status.unsure {
221 221 if cat_file_is_modified(repo, &to_check, &p1_hex)? {
222 222 rechecked_modified.push(to_check);
223 223 } else {
General Comments 0
You need to be logged in to leave comments. Login now