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.
--- 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
--- 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