# HG changeset patch # User Pierre-Yves David # Date 1654901921 -7200 # Node ID a87443d4aec026b1d9cecdf50e3289da6112e631 # Parent 0540c1628fd45bedc504696b266229fcec7e6333 sparse: directly inline the `walk` wrapping core is already aware of sparse, so lets move the handful of line of code that deal with it in `dirstate.walk` for the sake of simplicity. diff -r 0540c1628fd4 -r a87443d4aec0 hgext/sparse.py --- a/hgext/sparse.py Sat Jun 11 00:56:50 2022 +0200 +++ b/hgext/sparse.py Sat Jun 11 00:58:41 2022 +0200 @@ -81,7 +81,6 @@ error, extensions, logcmdutil, - match as matchmod, merge as mergemod, pycompat, registrar, @@ -213,18 +212,6 @@ and to prevent modifications to files outside the checkout. """ - def walk(orig, self, match, subrepos, unknown, ignored, full=True): - # hack to not exclude explicitly-specified paths so that they can - # be warned later on e.g. dirstate.add() - sparse_matcher = self._sparsematcher - if sparse_matcher is not None: - em = matchmod.exact(match.files()) - sm = matchmod.unionmatcher([self._sparsematcher, em]) - match = matchmod.intersectmatchers(match, sm) - return orig(self, match, subrepos, unknown, ignored, full) - - extensions.wrapfunction(dirstate.dirstate, b'walk', walk) - # dirstate.rebuild should not add non-matching files def _rebuild(orig, self, parent, allfiles, changedfiles=None): matcher = self._sparsematcher diff -r 0540c1628fd4 -r a87443d4aec0 mercurial/dirstate.py --- a/mercurial/dirstate.py Sat Jun 11 00:56:50 2022 +0200 +++ b/mercurial/dirstate.py Sat Jun 11 00:58:41 2022 +0200 @@ -984,6 +984,11 @@ ignore = util.always dirignore = util.always + if self._sparsematchfn is not None: + em = matchmod.exact(match.files()) + sm = matchmod.unionmatcher([self._sparsematcher, em]) + match = matchmod.intersectmatchers(match, sm) + matchfn = match.matchfn matchalways = match.always() matchtdir = match.traversedir