Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 50128:2f60cd6442fd
dirstate: only reload the dirstate when it may have changed
This reinstall the equivalent of what the `filecache` was doing. However it does
it at the dirstate level.
There is a double motivation for this:
- This avoid duplicating logic with the dirstate "identity" logic.
- This increase the lifetime of the `dirstate` object, helping to implement
change scoping.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 22 Feb 2023 01:08:25 +0100 |
parents | ec769cbc1fa2 |
children | 8bc14ac53a41 |
comparison
equal
deleted
inserted
replaced
50127:ec769cbc1fa2 | 50128:2f60cd6442fd |
---|---|
1463 # - new obsolescence marker, | 1463 # - new obsolescence marker, |
1464 # - working directory parent change, | 1464 # - working directory parent change, |
1465 # - bookmark changes | 1465 # - bookmark changes |
1466 self.filteredrevcache = {} | 1466 self.filteredrevcache = {} |
1467 | 1467 |
1468 self._dirstate = None | |
1468 # post-dirstate-status hooks | 1469 # post-dirstate-status hooks |
1469 self._postdsstatus = [] | 1470 self._postdsstatus = [] |
1470 | 1471 |
1471 # generic mapping between names and nodes | 1472 # generic mapping between names and nodes |
1472 self.names = namespaces.namespaces() | 1473 self.names = namespaces.namespaces() |
1750 def manifestlog(self): | 1751 def manifestlog(self): |
1751 return self.store.manifestlog(self, self._storenarrowmatch) | 1752 return self.store.manifestlog(self, self._storenarrowmatch) |
1752 | 1753 |
1753 @unfilteredpropertycache | 1754 @unfilteredpropertycache |
1754 def dirstate(self): | 1755 def dirstate(self): |
1755 # XXX This is known to be missing smarter caching. Check the next | 1756 if self._dirstate is None: |
1756 # changesets | 1757 self._dirstate = self._makedirstate() |
1757 return self._makedirstate() | 1758 else: |
1759 self._dirstate.refresh() | |
1760 return self._dirstate | |
1758 | 1761 |
1759 def _makedirstate(self): | 1762 def _makedirstate(self): |
1760 """Extension point for wrapping the dirstate per-repo.""" | 1763 """Extension point for wrapping the dirstate per-repo.""" |
1761 sparsematchfn = None | 1764 sparsematchfn = None |
1762 if sparse.use_sparse(self): | 1765 if sparse.use_sparse(self): |