rust-status: honor matcher when using the dirstate-only fast-path (issue6483) stable
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 10 Feb 2021 21:46:29 +0100
branchstable
changeset 46489 fb6eca7b8c63
parent 46488 40c8ae49561d
child 46490 86b019899737
rust-status: honor matcher when using the dirstate-only fast-path (issue6483) Differential Revision: https://phab.mercurial-scm.org/D9977
rust/hg-core/src/dirstate/status.rs
tests/test-status.t
--- a/rust/hg-core/src/dirstate/status.rs	Wed Feb 10 22:01:23 2021 +0100
+++ b/rust/hg-core/src/dirstate/status.rs	Wed Feb 10 21:46:29 2021 +0100
@@ -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
--- a/tests/test-status.t	Wed Feb 10 22:01:23 2021 +0100
+++ b/tests/test-status.t	Wed Feb 10 21:46:29 2021 +0100
@@ -691,4 +691,3 @@
   $ hg add a.py b.rs
   $ hg st -aI "*.py"
   A a.py
-  A b.rs (known-bad-output rust !)