diff -r bd3519dc6741 -r c2092612c424 mercurial/dirstate.py --- a/mercurial/dirstate.py Fri Jun 10 23:19:04 2022 +0200 +++ b/mercurial/dirstate.py Sat Jun 11 00:26:25 2022 +0200 @@ -1178,6 +1178,10 @@ return results def _rust_status(self, matcher, list_clean, list_ignored, list_unknown): + if self._sparsematchfn is not None: + em = matchmod.exact(matcher.files()) + sm = matchmod.unionmatcher([self._sparsematcher, em]) + matcher = matchmod.intersectmatchers(matcher, sm) # Force Rayon (Rust parallelism library) to respect the number of # workers. This is a temporary workaround until Rust code knows # how to read the config file. @@ -1296,8 +1300,6 @@ use_rust = False elif subrepos: use_rust = False - elif self._sparsematchfn is not None: - use_rust = False elif not isinstance(match, allowed_matchers): # Some matchers have yet to be implemented use_rust = False