Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/dirstate/status.rs @ 44973:26114bd6ec60
rust: do a clippy pass
This is the result of running `cargo clippy` on hg-core/hg-cpython and fixing
the lints that do not require too much code churn (and would warrant a separate
commit/complete refactor) and only come from our code (a lot of warnings in
hg-cpython come from `rust-cpython`).
Most of those were good lints, two of them was the linter not being smart
enough (or compiler to get up to `clippy`'s level depending on how you see it).
Maybe in the future we could have `clippy` be part of the CI.
Differential Revision: https://phab.mercurial-scm.org/D8635
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 15 Jun 2020 18:26:40 +0200 |
parents | 14125dec0e39 |
children | 7528699c6ccb |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/status.rs Mon Jun 15 15:14:16 2020 -0400 +++ b/rust/hg-core/src/dirstate/status.rs Mon Jun 15 18:26:40 2020 +0200 @@ -127,7 +127,7 @@ if skip_dot_hg && filename.as_bytes() == b".hg" && file_type.is_dir() { return Ok(vec![]); } else { - results.push((HgPathBuf::from(filename), entry)) + results.push((filename, entry)) } } @@ -164,14 +164,15 @@ (mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; + if metadata_changed || other_parent || copy_map.contains_key(filename.as_ref()) { Dispatch::Modified - } else if mod_compare(mtime, st_mtime as i32) { - Dispatch::Unsure - } else if st_mtime == options.last_normal_time { + } else if mod_compare(mtime, st_mtime as i32) + || st_mtime == options.last_normal_time + { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly @@ -226,9 +227,9 @@ files .unwrap_or(&DEFAULT_WORK) .par_iter() - .map(move |filename| { + .map(move |&filename| { // TODO normalization - let normalized = filename.as_ref(); + let normalized = filename; let buf = match hg_path_to_path_buf(normalized) { Ok(x) => x, @@ -254,33 +255,31 @@ ))); } Some(Ok((normalized, Dispatch::Unknown))) + } else if file_type.is_dir() { + if options.collect_traversed_dirs { + traversed_sender + .send(normalized.to_owned()) + .expect("receiver should outlive sender"); + } + Some(Ok(( + normalized, + Dispatch::Directory { + was_file: in_dmap.is_some(), + }, + ))) } else { - if file_type.is_dir() { - if options.collect_traversed_dirs { - traversed_sender - .send(normalized.to_owned()) - .expect("receiver should outlive sender"); - } - Some(Ok(( - normalized, - Dispatch::Directory { - was_file: in_dmap.is_some(), - }, - ))) - } else { - Some(Ok(( - normalized, - Dispatch::Bad(BadMatch::BadType( - // TODO do more than unknown - // Support for all `BadType` variant - // varies greatly between platforms. - // So far, no tests check the type and - // this should be good enough for most - // users. - BadType::Unknown, - )), - ))) - } + Some(Ok(( + normalized, + Dispatch::Bad(BadMatch::BadType( + // TODO do more than unknown + // Support for all `BadType` variant + // varies greatly between platforms. + // So far, no tests check the type and + // this should be good enough for most + // users. + BadType::Unknown, + )), + ))) }; } Err(_) => { @@ -381,12 +380,10 @@ .send(Ok((filename.to_owned(), Dispatch::Ignored))) .unwrap(); } - } else { - if options.list_unknown { - files_sender - .send(Ok((filename.to_owned(), Dispatch::Unknown))) - .unwrap(); - } + } else if options.list_unknown { + files_sender + .send(Ok((filename.to_owned(), Dispatch::Unknown))) + .unwrap(); } } else if ignore_fn(&filename) && options.list_ignored { files_sender