##// 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 use crate::dirstate_tree::dirstate_map::NodeRef;
8 use crate::dirstate_tree::dirstate_map::NodeRef;
9 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
9 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
10 use crate::matchers::get_ignore_function;
10 use crate::matchers::get_ignore_function;
11 use crate::matchers::Matcher;
11 use crate::matchers::{Matcher, VisitChildrenSet};
12 use crate::utils::files::get_bytes_from_os_string;
12 use crate::utils::files::get_bytes_from_os_string;
13 use crate::utils::files::get_bytes_from_path;
13 use crate::utils::files::get_bytes_from_path;
14 use crate::utils::files::get_path_from_bytes;
14 use crate::utils::files::get_path_from_bytes;
@@ -382,6 +382,16 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
382 false
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 /// Returns whether all child entries of the filesystem directory have a
395 /// Returns whether all child entries of the filesystem directory have a
386 /// corresponding dirstate node or are ignored.
396 /// corresponding dirstate node or are ignored.
387 fn traverse_fs_directory_and_dirstate<'ancestor>(
397 fn traverse_fs_directory_and_dirstate<'ancestor>(
@@ -393,14 +403,24 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
393 cached_directory_mtime: Option<TruncatedTimestamp>,
403 cached_directory_mtime: Option<TruncatedTimestamp>,
394 is_at_repo_root: bool,
404 is_at_repo_root: bool,
395 ) -> Result<bool, DirstateV2ParseError> {
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 if self.can_skip_fs_readdir(directory_entry, cached_directory_mtime) {
410 if self.can_skip_fs_readdir(directory_entry, cached_directory_mtime) {
397 dirstate_nodes
411 dirstate_nodes
398 .par_iter()
412 .par_iter()
399 .map(|dirstate_node| {
413 .map(|dirstate_node| {
400 let fs_path = &directory_entry.fs_path;
414 let fs_path = &directory_entry.fs_path;
401 let fs_path = fs_path.join(get_path_from_bytes(
415 let basename =
402 dirstate_node.base_name(self.dmap.on_disk)?.as_bytes(),
416 dirstate_node.base_name(self.dmap.on_disk)?.as_bytes();
403 ));
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 match std::fs::symlink_metadata(&fs_path) {
424 match std::fs::symlink_metadata(&fs_path) {
405 Ok(fs_metadata) => {
425 Ok(fs_metadata) => {
406 let file_type = fs_metadata.file_type().into();
426 let file_type = fs_metadata.file_type().into();
@@ -483,6 +503,15 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
483 .par_bridge()
503 .par_bridge()
484 .map(|pair| {
504 .map(|pair| {
485 use itertools::EitherOrBoth::*;
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 let has_dirstate_node_or_is_ignored = match pair {
515 let has_dirstate_node_or_is_ignored = match pair {
487 Both(dirstate_node, fs_entry) => {
516 Both(dirstate_node, fs_entry) => {
488 self.traverse_fs_and_dirstate(
517 self.traverse_fs_and_dirstate(
General Comments 0
You need to be logged in to leave comments. Login now