Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstate.py @ 49360: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 | bd3519dc6741 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Sat Jun 11 00:58:41 2022 +0200 +++ b/mercurial/dirstate.py Sat Jun 11 00:59:11 2022 +0200 @@ -670,6 +670,20 @@ self._dirty = True def rebuild(self, parent, allfiles, changedfiles=None): + + matcher = self._sparsematcher + if matcher is not None and not matcher.always(): + # should not add non-matching files + allfiles = [f for f in allfiles if matcher(f)] + if changedfiles: + changedfiles = [f for f in changedfiles if matcher(f)] + + if changedfiles is not None: + # these files will be deleted from the dirstate when they are + # not found to be in allfiles + dirstatefilestoremove = {f for f in self if not matcher(f)} + changedfiles = dirstatefilestoremove.union(changedfiles) + if changedfiles is None: # Rebuild entire dirstate to_lookup = allfiles