##// END OF EJS Templates
rhg: parallellize computation of [unsure_is_modified]...
Arseniy Alekseyev -
r50412:52464a20 default
parent child Browse files
Show More
@@ -981,6 +981,7 b' dependencies = ['
981 "lazy_static",
981 "lazy_static",
982 "log",
982 "log",
983 "micro-timer",
983 "micro-timer",
984 "rayon",
984 "regex",
985 "regex",
985 "users",
986 "users",
986 "which",
987 "which",
@@ -17,18 +17,21 b' pub struct Filelog {'
17 }
17 }
18
18
19 impl Filelog {
19 impl Filelog {
20 pub fn open(repo: &Repo, file_path: &HgPath) -> Result<Self, HgError> {
20 pub fn open_vfs(
21 store_vfs: &crate::vfs::Vfs<'_>,
22 file_path: &HgPath,
23 ) -> Result<Self, HgError> {
21 let index_path = store_path(file_path, b".i");
24 let index_path = store_path(file_path, b".i");
22 let data_path = store_path(file_path, b".d");
25 let data_path = store_path(file_path, b".d");
23 let revlog = Revlog::open(
26 let revlog =
24 &repo.store_vfs(),
27 Revlog::open(store_vfs, index_path, Some(&data_path), false)?;
25 index_path,
26 Some(&data_path),
27 false,
28 )?;
29 Ok(Self { revlog })
28 Ok(Self { revlog })
30 }
29 }
31
30
31 pub fn open(repo: &Repo, file_path: &HgPath) -> Result<Self, HgError> {
32 Self::open_vfs(&repo.store_vfs(), file_path)
33 }
34
32 /// The given node ID is that of the file as found in a filelog, not of a
35 /// The given node ID is that of the file as found in a filelog, not of a
33 /// changeset.
36 /// changeset.
34 pub fn data_for_node(
37 pub fn data_for_node(
@@ -97,7 +97,7 b' pub(crate) fn parse_config('
97 Includes,
97 Includes,
98 Excludes,
98 Excludes,
99 None,
99 None,
100 };
100 }
101
101
102 let mut current = Current::None;
102 let mut current = Current::None;
103 let mut in_section = false;
103 let mut in_section = false;
@@ -22,3 +22,4 b' env_logger = "0.9.0"'
22 format-bytes = "0.3.0"
22 format-bytes = "0.3.0"
23 users = "0.11.0"
23 users = "0.11.0"
24 which = "4.2.5"
24 which = "4.2.5"
25 rayon = "1.5.1"
@@ -29,6 +29,7 b' use hg::StatusError;'
29 use hg::StatusOptions;
29 use hg::StatusOptions;
30 use hg::{self, narrow, sparse};
30 use hg::{self, narrow, sparse};
31 use log::info;
31 use log::info;
32 use rayon::prelude::*;
32 use std::io;
33 use std::io;
33 use std::path::PathBuf;
34 use std::path::PathBuf;
34
35
@@ -291,16 +292,31 b' pub fn run(invocation: &crate::CliInvoca'
291 let manifest = repo.manifest_for_node(p1).map_err(|e| {
292 let manifest = repo.manifest_for_node(p1).map_err(|e| {
292 CommandError::from((e, &*format!("{:x}", p1.short())))
293 CommandError::from((e, &*format!("{:x}", p1.short())))
293 })?;
294 })?;
294 for to_check in ds_status.unsure {
295 let working_directory_vfs = repo.working_directory_vfs();
295 if unsure_is_modified(repo, &manifest, &to_check.path)? {
296 let store_vfs = repo.store_vfs();
297 let res: Vec<_> = ds_status
298 .unsure
299 .into_par_iter()
300 .map(|to_check| {
301 unsure_is_modified(
302 working_directory_vfs,
303 store_vfs,
304 &manifest,
305 &to_check.path,
306 )
307 .map(|modified| (to_check, modified))
308 })
309 .collect::<Result<_, _>>()?;
310 for (status_path, is_modified) in res.into_iter() {
311 if is_modified {
296 if display_states.modified {
312 if display_states.modified {
297 ds_status.modified.push(to_check);
313 ds_status.modified.push(status_path);
298 }
314 }
299 } else {
315 } else {
300 if display_states.clean {
316 if display_states.clean {
301 ds_status.clean.push(to_check.clone());
317 ds_status.clean.push(status_path.clone());
302 }
318 }
303 fixup.push(to_check.path.into_owned())
319 fixup.push(status_path.path.into_owned())
304 }
320 }
305 }
321 }
306 }
322 }
@@ -525,11 +541,12 b" impl DisplayStatusPaths<'_> {"
525 /// This meant to be used for those that the dirstate cannot resolve, due
541 /// This meant to be used for those that the dirstate cannot resolve, due
526 /// to time resolution limits.
542 /// to time resolution limits.
527 fn unsure_is_modified(
543 fn unsure_is_modified(
528 repo: &Repo,
544 working_directory_vfs: hg::vfs::Vfs,
545 store_vfs: hg::vfs::Vfs,
529 manifest: &Manifest,
546 manifest: &Manifest,
530 hg_path: &HgPath,
547 hg_path: &HgPath,
531 ) -> Result<bool, HgError> {
548 ) -> Result<bool, HgError> {
532 let vfs = repo.working_directory_vfs();
549 let vfs = working_directory_vfs;
533 let fs_path = hg_path_to_path_buf(hg_path).expect("HgPath conversion");
550 let fs_path = hg_path_to_path_buf(hg_path).expect("HgPath conversion");
534 let fs_metadata = vfs.symlink_metadata(&fs_path)?;
551 let fs_metadata = vfs.symlink_metadata(&fs_path)?;
535 let is_symlink = fs_metadata.file_type().is_symlink();
552 let is_symlink = fs_metadata.file_type().is_symlink();
@@ -549,7 +566,7 b' fn unsure_is_modified('
549 if entry.flags != fs_flags {
566 if entry.flags != fs_flags {
550 return Ok(true);
567 return Ok(true);
551 }
568 }
552 let filelog = repo.filelog(hg_path)?;
569 let filelog = hg::filelog::Filelog::open_vfs(&store_vfs, hg_path)?;
553 let fs_len = fs_metadata.len();
570 let fs_len = fs_metadata.len();
554 let file_node = entry.node_id()?;
571 let file_node = entry.node_id()?;
555 let filelog_entry = filelog.entry_for_node(file_node).map_err(|_| {
572 let filelog_entry = filelog.entry_for_node(file_node).map_err(|_| {
General Comments 0
You need to be logged in to leave comments. Login now