Patchwork D9977: rust-status: honor matcher when using the dirstate-only fast-path (issue6483)

login
register
mail settings
Submitter phabricator
Date Feb. 10, 2021, 9:27 p.m.
Message ID <differential-rev-PHID-DREV-7hypaddesjaofq6rdfd2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48292/
State Superseded
Headers show

Comments

phabricator - Feb. 10, 2021, 9:27 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  tests/test-status.t

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -691,4 +691,3 @@ 
   $ hg add a.py b.rs
   $ hg st -aI "*.py"
   A a.py
-  A b.rs (known-bad-output rust !)
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
@@ -792,58 +792,66 @@ 
     #[cfg(not(feature = "dirstate-tree"))]
     #[timed]
     pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) {
-        results.par_extend(self.dmap.par_iter().map(
-            move |(filename, entry)| {
-                let filename: &HgPath = filename;
-                let filename_as_path = match hg_path_to_path_buf(filename) {
-                    Ok(f) => f,
-                    Err(_) => {
-                        return (
+        results.par_extend(
+            self.dmap
+                .par_iter()
+                .filter(|(path, _)| self.matcher.matches(path))
+                .map(move |(filename, entry)| {
+                    let filename: &HgPath = filename;
+                    let filename_as_path = match hg_path_to_path_buf(filename)
+                    {
+                        Ok(f) => f,
+                        Err(_) => {
+                            return (
+                                Cow::Borrowed(filename),
+                                INVALID_PATH_DISPATCH,
+                            )
+                        }
+                    };
+                    let meta = self
+                        .root_dir
+                        .join(filename_as_path)
+                        .symlink_metadata();
+                    match meta {
+                        Ok(m)
+                            if !(m.file_type().is_file()
+                                || m.file_type().is_symlink()) =>
+                        {
+                            (
+                                Cow::Borrowed(filename),
+                                dispatch_missing(entry.state),
+                            )
+                        }
+                        Ok(m) => (
                             Cow::Borrowed(filename),
-                            INVALID_PATH_DISPATCH,
-                        )
-                    }
-                };
-                let meta =
-                    self.root_dir.join(filename_as_path).symlink_metadata();
-                match meta {
-                    Ok(m)
-                        if !(m.file_type().is_file()
-                            || m.file_type().is_symlink()) =>
-                    {
-                        (
-                            Cow::Borrowed(filename),
-                            dispatch_missing(entry.state),
-                        )
+                            dispatch_found(
+                                filename,
+                                *entry,
+                                HgMetadata::from_metadata(m),
+                                &self.dmap.copy_map,
+                                self.options,
+                            ),
+                        ),
+                        Err(e)
+                            if e.kind() == ErrorKind::NotFound
+                                || e.raw_os_error() == Some(20) =>
+                        {
+                            // Rust does not yet have an `ErrorKind` for
+                            // `NotADirectory` (errno 20)
+                            // It happens if the dirstate contains `foo/bar`
+                            // and foo is not a
+                            // directory
+                            (
+                                Cow::Borrowed(filename),
+                                dispatch_missing(entry.state),
+                            )
+                        }
+                        Err(e) => {
+                            (Cow::Borrowed(filename), dispatch_os_error(&e))
+                        }
                     }
-                    Ok(m) => (
-                        Cow::Borrowed(filename),
-                        dispatch_found(
-                            filename,
-                            *entry,
-                            HgMetadata::from_metadata(m),
-                            &self.dmap.copy_map,
-                            self.options,
-                        ),
-                    ),
-                    Err(e)
-                        if e.kind() == ErrorKind::NotFound
-                            || e.raw_os_error() == Some(20) =>
-                    {
-                        // Rust does not yet have an `ErrorKind` for
-                        // `NotADirectory` (errno 20)
-                        // It happens if the dirstate contains `foo/bar`
-                        // and foo is not a
-                        // directory
-                        (
-                            Cow::Borrowed(filename),
-                            dispatch_missing(entry.state),
-                        )
-                    }
-                    Err(e) => (Cow::Borrowed(filename), dispatch_os_error(&e)),
-                }
-            },
-        ));
+                }),
+        );
     }
 
     /// Checks all files that are in the dirstate but were not found during the