##// END OF EJS Templates
rust-status: remove dead code...
Raphaël Gomès -
r43761:ab9b0a20 default
parent child Browse files
Show More
@@ -1120,7 +1120,6 b' class dirstate(object):'
1120 ) = rustmod.status(
1120 ) = rustmod.status(
1121 dmap._rustmap,
1121 dmap._rustmap,
1122 self._rootdir,
1122 self._rootdir,
1123 match.files(),
1124 bool(listclean),
1123 bool(listclean),
1125 self._lastnormaltime,
1124 self._lastnormaltime,
1126 self._checkexec,
1125 self._checkexec,
@@ -10,68 +10,14 b''
10 //! and will only be triggered in narrow cases.
10 //! and will only be triggered in narrow cases.
11
11
12 use crate::utils::files::HgMetadata;
12 use crate::utils::files::HgMetadata;
13 use crate::utils::hg_path::{hg_path_to_path_buf, HgPath, HgPathBuf};
13 use crate::utils::hg_path::{hg_path_to_path_buf, HgPathBuf};
14 use crate::{DirstateEntry, DirstateMap, EntryState};
14 use crate::{DirstateEntry, DirstateMap, EntryState};
15 use rayon::prelude::*;
15 use rayon::prelude::*;
16 use std::collections::HashMap;
17 use std::fs::Metadata;
18 use std::path::Path;
16 use std::path::Path;
19
17
20 /// Get stat data about the files explicitly specified by match.
21 /// TODO subrepos
22 fn walk_explicit(
23 files: &[impl AsRef<HgPath> + Sync],
24 dmap: &DirstateMap,
25 root_dir: impl AsRef<Path> + Sync,
26 ) -> std::io::Result<HashMap<HgPathBuf, Option<HgMetadata>>> {
27 let mut results = HashMap::new();
28
29 // A tuple of the normalized filename and the `Result` of the call to
30 // `symlink_metadata` for separate handling.
31 type WalkTuple<'a> = (&'a HgPath, std::io::Result<Metadata>);
32
33 let stats_res: std::io::Result<Vec<WalkTuple>> = files
34 .par_iter()
35 .map(|filename| {
36 // TODO normalization
37 let normalized = filename.as_ref();
38
39 let target_filename =
40 root_dir.as_ref().join(hg_path_to_path_buf(normalized)?);
41
42 Ok((normalized, target_filename.symlink_metadata()))
43 })
44 .collect();
45
46 for res in stats_res? {
47 match res {
48 (normalized, Ok(stat)) => {
49 if stat.is_file() {
50 results.insert(
51 normalized.to_owned(),
52 Some(HgMetadata::from_metadata(stat)),
53 );
54 } else {
55 if dmap.contains_key(normalized) {
56 results.insert(normalized.to_owned(), None);
57 }
58 }
59 }
60 (normalized, Err(_)) => {
61 if dmap.contains_key(normalized) {
62 results.insert(normalized.to_owned(), None);
63 }
64 }
65 };
66 }
67
68 Ok(results)
69 }
70
71 // Stat all entries in the `DirstateMap` and return their new metadata.
18 // Stat all entries in the `DirstateMap` and return their new metadata.
72 pub fn stat_dmap_entries(
19 pub fn stat_dmap_entries(
73 dmap: &DirstateMap,
20 dmap: &DirstateMap,
74 results: &HashMap<HgPathBuf, Option<HgMetadata>>,
75 root_dir: impl AsRef<Path> + Sync,
21 root_dir: impl AsRef<Path> + Sync,
76 ) -> std::io::Result<Vec<(HgPathBuf, Option<HgMetadata>)>> {
22 ) -> std::io::Result<Vec<(HgPathBuf, Option<HgMetadata>)>> {
77 dmap.par_iter()
23 dmap.par_iter()
@@ -81,9 +27,6 b' pub fn stat_dmap_entries('
81 |(filename, _)| -> Option<
27 |(filename, _)| -> Option<
82 std::io::Result<(HgPathBuf, Option<HgMetadata>)>
28 std::io::Result<(HgPathBuf, Option<HgMetadata>)>
83 > {
29 > {
84 if results.contains_key(filename) {
85 return None;
86 }
87 let meta = match hg_path_to_path_buf(filename) {
30 let meta = match hg_path_to_path_buf(filename) {
88 Ok(p) => root_dir.as_ref().join(p).symlink_metadata(),
31 Ok(p) => root_dir.as_ref().join(p).symlink_metadata(),
89 Err(e) => return Some(Err(e.into())),
32 Err(e) => return Some(Err(e.into())),
@@ -132,7 +75,7 b' fn build_response('
132 list_clean: bool,
75 list_clean: bool,
133 last_normal_time: i64,
76 last_normal_time: i64,
134 check_exec: bool,
77 check_exec: bool,
135 results: HashMap<HgPathBuf, Option<HgMetadata>>,
78 results: Vec<(HgPathBuf, Option<HgMetadata>)>,
136 ) -> (Vec<HgPathBuf>, StatusResult) {
79 ) -> (Vec<HgPathBuf>, StatusResult) {
137 let mut lookup = vec![];
80 let mut lookup = vec![];
138 let mut modified = vec![];
81 let mut modified = vec![];
@@ -229,14 +172,11 b' fn build_response('
229 pub fn status(
172 pub fn status(
230 dmap: &DirstateMap,
173 dmap: &DirstateMap,
231 root_dir: impl AsRef<Path> + Sync + Copy,
174 root_dir: impl AsRef<Path> + Sync + Copy,
232 files: &[impl AsRef<HgPath> + Sync],
233 list_clean: bool,
175 list_clean: bool,
234 last_normal_time: i64,
176 last_normal_time: i64,
235 check_exec: bool,
177 check_exec: bool,
236 ) -> std::io::Result<(Vec<HgPathBuf>, StatusResult)> {
178 ) -> std::io::Result<(Vec<HgPathBuf>, StatusResult)> {
237 let mut results = walk_explicit(files, &dmap, root_dir)?;
179 let results = stat_dmap_entries(&dmap, root_dir)?;
238
239 results.extend(stat_dmap_entries(&dmap, &results, root_dir)?);
240
180
241 Ok(build_response(
181 Ok(build_response(
242 &dmap,
182 &dmap,
@@ -17,8 +17,8 b' use crate::dirstate::{'
17 dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper,
17 dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper,
18 };
18 };
19 use cpython::{
19 use cpython::{
20 exc, PyBytes, PyDict, PyErr, PyList, PyModule, PyObject, PyResult,
20 exc, PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence,
21 PySequence, Python,
21 Python,
22 };
22 };
23 use hg::{
23 use hg::{
24 utils::hg_path::HgPathBuf, DirstateEntry, DirstateParseError, EntryState,
24 utils::hg_path::HgPathBuf, DirstateEntry, DirstateParseError, EntryState,
@@ -116,7 +116,6 b' pub fn init_module(py: Python, package: '
116 status_wrapper(
116 status_wrapper(
117 dmap: DirstateMap,
117 dmap: DirstateMap,
118 root_dir: PyObject,
118 root_dir: PyObject,
119 files: PyList,
120 list_clean: bool,
119 list_clean: bool,
121 last_normal_time: i64,
120 last_normal_time: i64,
122 check_exec: bool
121 check_exec: bool
@@ -18,8 +18,8 b' use cpython::{'
18 };
18 };
19 use hg::utils::files::get_path_from_bytes;
19 use hg::utils::files::get_path_from_bytes;
20
20
21 use hg::status;
21 use hg::utils::hg_path::HgPath;
22 use hg::utils::hg_path::HgPath;
22 use hg::{status, utils::hg_path::HgPathBuf};
23
23
24 /// This will be useless once trait impls for collection are added to `PyBytes`
24 /// This will be useless once trait impls for collection are added to `PyBytes`
25 /// upstream.
25 /// upstream.
@@ -44,7 +44,6 b' pub fn status_wrapper('
44 py: Python,
44 py: Python,
45 dmap: DirstateMap,
45 dmap: DirstateMap,
46 root_dir: PyObject,
46 root_dir: PyObject,
47 files: PyList,
48 list_clean: bool,
47 list_clean: bool,
49 last_normal_time: i64,
48 last_normal_time: i64,
50 check_exec: bool,
49 check_exec: bool,
@@ -55,21 +54,9 b' pub fn status_wrapper('
55 let dmap: DirstateMap = dmap.to_py_object(py);
54 let dmap: DirstateMap = dmap.to_py_object(py);
56 let dmap = dmap.get_inner(py);
55 let dmap = dmap.get_inner(py);
57
56
58 let files: PyResult<Vec<HgPathBuf>> = files
57 let (lookup, status_res) =
59 .iter(py)
58 status(&dmap, &root_dir, list_clean, last_normal_time, check_exec)
60 .map(|f| Ok(HgPathBuf::from_bytes(f.extract::<PyBytes>(py)?.data(py))))
59 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?;
61 .collect();
62 let files = files?;
63
64 let (lookup, status_res) = status(
65 &dmap,
66 &root_dir,
67 &files,
68 list_clean,
69 last_normal_time,
70 check_exec,
71 )
72 .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?;
73
60
74 let modified = collect_pybytes_list(py, status_res.modified.as_ref());
61 let modified = collect_pybytes_list(py, status_res.modified.as_ref());
75 let added = collect_pybytes_list(py, status_res.added.as_ref());
62 let added = collect_pybytes_list(py, status_res.added.as_ref());
General Comments 0
You need to be logged in to leave comments. Login now