# HG changeset patch # User Pierre-Yves David # Date 1677024295 -3600 # Node ID ec769cbc1fa21f1f6193ee257dae157c7c3a9be1 # Parent 85746485a4ddf441b0f9d50ecc31401fa9a53b77 dirstate: directly manage the dirstate property on localrepo Before we had: * the filecache layer on `localrepo` doing some caching * the dirstate having some internal invalidation/refresh machanism * the status code doing some identity validation. To clean this up, we are dropping the first item "localrepo `filecache`" from the equation in a favor of an approach integrated into the dirstate (second item) in the next changesets. This changeset will be a small windows where some things will be a bit slower. This will be fixed in the next changesets. diff -r 85746485a4dd -r ec769cbc1fa2 mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Feb 21 15:10:12 2023 +0100 +++ b/mercurial/localrepo.py Wed Feb 22 01:04:55 2023 +0100 @@ -1750,8 +1750,10 @@ def manifestlog(self): return self.store.manifestlog(self, self._storenarrowmatch) - @repofilecache(b'dirstate') + @unfilteredpropertycache def dirstate(self): + # XXX This is known to be missing smarter caching. Check the next + # changesets return self._makedirstate() def _makedirstate(self): @@ -2965,13 +2967,9 @@ rereads the dirstate. Use dirstate.invalidate() if you want to explicitly read the dirstate again (i.e. restoring it to a previous known good state).""" - if hasunfilteredcache(self, 'dirstate'): - for k in self.dirstate._filecache: - try: - delattr(self.dirstate, k) - except AttributeError: - pass - delattr(self.unfiltered(), 'dirstate') + unfi = self.unfiltered() + if 'dirstate' in unfi.__dict__: + del unfi.__dict__['dirstate'] def invalidate(self, clearfilecache=False): """Invalidates both store and non-store parts other than dirstate @@ -2983,9 +2981,6 @@ """ unfiltered = self.unfiltered() # all file caches are stored unfiltered for k in list(self._filecache.keys()): - # dirstate is invalidated separately in invalidatedirstate() - if k == b'dirstate': - continue if ( k == b'changelog' and self.currenttransaction() @@ -3124,7 +3119,9 @@ self.ui.develwarn(msg) self.dirstate.write(None) - self._filecache[b'dirstate'].refresh() + unfi = self.unfiltered() + if 'dirstate' in unfi.__dict__: + del unfi.__dict__['dirstate'] l = self._lock( self.vfs,