comparison hgext/sparse.py @ 49356:a87443d4aec0

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 11 Jun 2022 00:58:41 +0200
parents 0540c1628fd4
children 5b7a10ddb42f
comparison
equal deleted inserted replaced
49355:0540c1628fd4 49356:a87443d4aec0
79 commands, 79 commands,
80 dirstate, 80 dirstate,
81 error, 81 error,
82 extensions, 82 extensions,
83 logcmdutil, 83 logcmdutil,
84 match as matchmod,
85 merge as mergemod, 84 merge as mergemod,
86 pycompat, 85 pycompat,
87 registrar, 86 registrar,
88 sparse, 87 sparse,
89 util, 88 util,
210 209
211 def _setupdirstate(ui): 210 def _setupdirstate(ui):
212 """Modify the dirstate to prevent stat'ing excluded files, 211 """Modify the dirstate to prevent stat'ing excluded files,
213 and to prevent modifications to files outside the checkout. 212 and to prevent modifications to files outside the checkout.
214 """ 213 """
215
216 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
217 # hack to not exclude explicitly-specified paths so that they can
218 # be warned later on e.g. dirstate.add()
219 sparse_matcher = self._sparsematcher
220 if sparse_matcher is not None:
221 em = matchmod.exact(match.files())
222 sm = matchmod.unionmatcher([self._sparsematcher, em])
223 match = matchmod.intersectmatchers(match, sm)
224 return orig(self, match, subrepos, unknown, ignored, full)
225
226 extensions.wrapfunction(dirstate.dirstate, b'walk', walk)
227 214
228 # dirstate.rebuild should not add non-matching files 215 # dirstate.rebuild should not add non-matching files
229 def _rebuild(orig, self, parent, allfiles, changedfiles=None): 216 def _rebuild(orig, self, parent, allfiles, changedfiles=None):
230 matcher = self._sparsematcher 217 matcher = self._sparsematcher
231 if matcher is not None and not matcher.always(): 218 if matcher is not None and not matcher.always():