comparison hgext/sparse.py @ 49357:5b7a10ddb42f

sparse: directly inline the `rebuild` wrapping Core is already aware of sparse, so lets move the handful of line of code that deal with it in `dirstate.rebuild` for the sake of simplicity.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 11 Jun 2022 00:59:11 +0200
parents a87443d4aec0
children 05da1f1612db
comparison
equal deleted inserted replaced
49356:a87443d4aec0 49357:5b7a10ddb42f
209 209
210 def _setupdirstate(ui): 210 def _setupdirstate(ui):
211 """Modify the dirstate to prevent stat'ing excluded files, 211 """Modify the dirstate to prevent stat'ing excluded files,
212 and to prevent modifications to files outside the checkout. 212 and to prevent modifications to files outside the checkout.
213 """ 213 """
214
215 # dirstate.rebuild should not add non-matching files
216 def _rebuild(orig, self, parent, allfiles, changedfiles=None):
217 matcher = self._sparsematcher
218 if matcher is not None and not matcher.always():
219 allfiles = [f for f in allfiles if matcher(f)]
220 if changedfiles:
221 changedfiles = [f for f in changedfiles if matcher(f)]
222
223 if changedfiles is not None:
224 # In _rebuild, these files will be deleted from the dirstate
225 # when they are not found to be in allfiles
226 dirstatefilestoremove = {f for f in self if not matcher(f)}
227 changedfiles = dirstatefilestoremove.union(changedfiles)
228
229 return orig(self, parent, allfiles, changedfiles)
230
231 extensions.wrapfunction(dirstate.dirstate, b'rebuild', _rebuild)
232 214
233 # Prevent adding files that are outside the sparse checkout 215 # Prevent adding files that are outside the sparse checkout
234 editfuncs = [ 216 editfuncs = [
235 b'set_tracked', 217 b'set_tracked',
236 b'set_untracked', 218 b'set_untracked',