D7253: rust-status: remove dead code

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Wed Nov 6 13:59:56 EST 2019


Closed by commit rHGab9b0a20b9e6: rust-status: remove dead code (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7253?vs=17621&id=17628

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7253/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7253

AFFECTED FILES
  mercurial/dirstate.py
  rust/hg-core/src/dirstate/status.rs
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS

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<Vec<HgPathBuf>> = files
-        .iter(py)
-        .map(|f| Ok(HgPathBuf::from_bytes(f.extract::<PyBytes>(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::<ValueError, _>(py, e.to_string()))?;
+    let (lookup, status_res) =
+        status(&dmap, &root_dir, list_clean, last_normal_time, check_exec)
+            .map_err(|e| PyErr::new::<ValueError, _>(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());
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-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<HgPath> + Sync],
-    dmap: &DirstateMap,
-    root_dir: impl AsRef<Path> + Sync,
-) -> std::io::Result<HashMap<HgPathBuf, Option<HgMetadata>>> {
-    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<Metadata>);
-
-    let stats_res: std::io::Result<Vec<WalkTuple>> = 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<HgPathBuf, Option<HgMetadata>>,
     root_dir: impl AsRef<Path> + Sync,
 ) -> std::io::Result<Vec<(HgPathBuf, Option<HgMetadata>)>> {
     dmap.par_iter()
@@ -81,9 +27,6 @@
             |(filename, _)| -> Option<
                 std::io::Result<(HgPathBuf, Option<HgMetadata>)>
             > {
-                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<HgPathBuf, Option<HgMetadata>>,
+    results: Vec<(HgPathBuf, Option<HgMetadata>)>,
 ) -> (Vec<HgPathBuf>, StatusResult) {
     let mut lookup = vec![];
     let mut modified = vec![];
@@ -229,14 +172,11 @@
 pub fn status(
     dmap: &DirstateMap,
     root_dir: impl AsRef<Path> + Sync + Copy,
-    files: &[impl AsRef<HgPath> + Sync],
     list_clean: bool,
     last_normal_time: i64,
     check_exec: bool,
 ) -> std::io::Result<(Vec<HgPathBuf>, 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/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,



To: Alphare, #hg-reviewers, kevincox
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list