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', |