##// END OF EJS Templates
rust-status: only visit parts of the tree requested by the matcher...
Spencer Baugh -
r51757:76387f79 default
parent child Browse files
Show More
@@ -8,7 +8,7 b' use crate::dirstate_tree::dirstate_map::'
8 8 use crate::dirstate_tree::dirstate_map::NodeRef;
9 9 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
10 10 use crate::matchers::get_ignore_function;
11 use crate::matchers::Matcher;
11 use crate::matchers::{Matcher, VisitChildrenSet};
12 12 use crate::utils::files::get_bytes_from_os_string;
13 13 use crate::utils::files::get_bytes_from_path;
14 14 use crate::utils::files::get_path_from_bytes;
@@ -382,6 +382,16 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
382 382 false
383 383 }
384 384
385 fn should_visit(set: &VisitChildrenSet, basename: &HgPath) -> bool {
386 match set {
387 VisitChildrenSet::This | VisitChildrenSet::Recursive => true,
388 VisitChildrenSet::Empty => false,
389 VisitChildrenSet::Set(children_to_visit) => {
390 children_to_visit.contains(basename)
391 }
392 }
393 }
394
385 395 /// Returns whether all child entries of the filesystem directory have a
386 396 /// corresponding dirstate node or are ignored.
387 397 fn traverse_fs_directory_and_dirstate<'ancestor>(
@@ -393,14 +403,24 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
393 403 cached_directory_mtime: Option<TruncatedTimestamp>,
394 404 is_at_repo_root: bool,
395 405 ) -> Result<bool, DirstateV2ParseError> {
406 let children_set = self.matcher.visit_children_set(directory_hg_path);
407 if let VisitChildrenSet::Empty = children_set {
408 return Ok(false);
409 }
396 410 if self.can_skip_fs_readdir(directory_entry, cached_directory_mtime) {
397 411 dirstate_nodes
398 412 .par_iter()
399 413 .map(|dirstate_node| {
400 414 let fs_path = &directory_entry.fs_path;
401 let fs_path = fs_path.join(get_path_from_bytes(
402 dirstate_node.base_name(self.dmap.on_disk)?.as_bytes(),
403 ));
415 let basename =
416 dirstate_node.base_name(self.dmap.on_disk)?.as_bytes();
417 let fs_path = fs_path.join(get_path_from_bytes(basename));
418 if !Self::should_visit(
419 &children_set,
420 HgPath::new(basename),
421 ) {
422 return Ok(());
423 }
404 424 match std::fs::symlink_metadata(&fs_path) {
405 425 Ok(fs_metadata) => {
406 426 let file_type = fs_metadata.file_type().into();
@@ -483,6 +503,15 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
483 503 .par_bridge()
484 504 .map(|pair| {
485 505 use itertools::EitherOrBoth::*;
506 let basename = match &pair {
507 Left(dirstate_node) | Both(dirstate_node, _) => HgPath::new(
508 dirstate_node.base_name(self.dmap.on_disk)?.as_bytes(),
509 ),
510 Right(fs_entry) => &fs_entry.hg_path,
511 };
512 if !Self::should_visit(&children_set, basename) {
513 return Ok(false);
514 }
486 515 let has_dirstate_node_or_is_ignored = match pair {
487 516 Both(dirstate_node, fs_entry) => {
488 517 self.traverse_fs_and_dirstate(
General Comments 0
You need to be logged in to leave comments. Login now