diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1120,7 +1120,6 @@ ) = rustmod.status( dmap._rustmap, self._rootdir, - match.files(), bool(listclean), self._lastnormaltime, self._checkexec, diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -10,68 +10,14 @@ //! and will only be triggered in narrow cases. use crate::utils::files::HgMetadata; -use crate::utils::hg_path::{hg_path_to_path_buf, HgPath, HgPathBuf}; +use crate::utils::hg_path::{hg_path_to_path_buf, HgPathBuf}; use crate::{DirstateEntry, DirstateMap, EntryState}; use rayon::prelude::*; -use std::collections::HashMap; -use std::fs::Metadata; use std::path::Path; -/// Get stat data about the files explicitly specified by match. -/// TODO subrepos -fn walk_explicit( - files: &[impl AsRef + Sync], - dmap: &DirstateMap, - root_dir: impl AsRef + Sync, -) -> std::io::Result>> { - let mut results = HashMap::new(); - - // A tuple of the normalized filename and the `Result` of the call to - // `symlink_metadata` for separate handling. - type WalkTuple<'a> = (&'a HgPath, std::io::Result); - - let stats_res: std::io::Result> = files - .par_iter() - .map(|filename| { - // TODO normalization - let normalized = filename.as_ref(); - - let target_filename = - root_dir.as_ref().join(hg_path_to_path_buf(normalized)?); - - Ok((normalized, target_filename.symlink_metadata())) - }) - .collect(); - - for res in stats_res? { - match res { - (normalized, Ok(stat)) => { - if stat.is_file() { - results.insert( - normalized.to_owned(), - Some(HgMetadata::from_metadata(stat)), - ); - } else { - if dmap.contains_key(normalized) { - results.insert(normalized.to_owned(), None); - } - } - } - (normalized, Err(_)) => { - if dmap.contains_key(normalized) { - results.insert(normalized.to_owned(), None); - } - } - }; - } - - Ok(results) -} - // Stat all entries in the `DirstateMap` and return their new metadata. pub fn stat_dmap_entries( dmap: &DirstateMap, - results: &HashMap>, root_dir: impl AsRef + Sync, ) -> std::io::Result)>> { dmap.par_iter() @@ -81,9 +27,6 @@ |(filename, _)| -> Option< std::io::Result<(HgPathBuf, Option)> > { - if results.contains_key(filename) { - return None; - } let meta = match hg_path_to_path_buf(filename) { Ok(p) => root_dir.as_ref().join(p).symlink_metadata(), Err(e) => return Some(Err(e.into())), @@ -132,7 +75,7 @@ list_clean: bool, last_normal_time: i64, check_exec: bool, - results: HashMap>, + results: Vec<(HgPathBuf, Option)>, ) -> (Vec, StatusResult) { let mut lookup = vec![]; let mut modified = vec![]; @@ -229,14 +172,11 @@ pub fn status( dmap: &DirstateMap, root_dir: impl AsRef + Sync + Copy, - files: &[impl AsRef + Sync], list_clean: bool, last_normal_time: i64, check_exec: bool, ) -> std::io::Result<(Vec, StatusResult)> { - let mut results = walk_explicit(files, &dmap, root_dir)?; - - results.extend(stat_dmap_entries(&dmap, &results, root_dir)?); + let results = stat_dmap_entries(&dmap, root_dir)?; Ok(build_response( &dmap, diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs --- a/rust/hg-cpython/src/dirstate.rs +++ b/rust/hg-cpython/src/dirstate.rs @@ -17,8 +17,8 @@ dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper, }; use cpython::{ - exc, PyBytes, PyDict, PyErr, PyList, PyModule, PyObject, PyResult, - PySequence, Python, + exc, PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence, + Python, }; use hg::{ utils::hg_path::HgPathBuf, DirstateEntry, DirstateParseError, EntryState, @@ -116,7 +116,6 @@ status_wrapper( dmap: DirstateMap, root_dir: PyObject, - files: PyList, list_clean: bool, last_normal_time: i64, check_exec: bool diff --git a/rust/hg-cpython/src/dirstate/status.rs b/rust/hg-cpython/src/dirstate/status.rs --- a/rust/hg-cpython/src/dirstate/status.rs +++ b/rust/hg-cpython/src/dirstate/status.rs @@ -18,8 +18,8 @@ }; use hg::utils::files::get_path_from_bytes; +use hg::status; use hg::utils::hg_path::HgPath; -use hg::{status, utils::hg_path::HgPathBuf}; /// This will be useless once trait impls for collection are added to `PyBytes` /// upstream. @@ -44,7 +44,6 @@ py: Python, dmap: DirstateMap, root_dir: PyObject, - files: PyList, list_clean: bool, last_normal_time: i64, check_exec: bool, @@ -55,21 +54,9 @@ let dmap: DirstateMap = dmap.to_py_object(py); let dmap = dmap.get_inner(py); - let files: PyResult> = files - .iter(py) - .map(|f| Ok(HgPathBuf::from_bytes(f.extract::(py)?.data(py)))) - .collect(); - let files = files?; - - let (lookup, status_res) = status( - &dmap, - &root_dir, - &files, - list_clean, - last_normal_time, - check_exec, - ) - .map_err(|e| PyErr::new::(py, e.to_string()))?; + let (lookup, status_res) = + status(&dmap, &root_dir, list_clean, last_normal_time, check_exec) + .map_err(|e| PyErr::new::(py, e.to_string()))?; let modified = collect_pybytes_list(py, status_res.modified.as_ref()); let added = collect_pybytes_list(py, status_res.added.as_ref());