# HG changeset patch # User Durham Goode # Date 2017-10-26 23:15:36 # Node ID 6e66033f91ccfb7666ec0a25d19954673269c61a # Parent 0217f75b6e59cc098f99b6238ea50e121bcefd42 dirstate: avoid reading the map when possible (issue5713) (issue5717) Before the recent refactor, we would not load the entire map until it was accessed. As part of the refactor, that got lost and even just trying to load the dirstate parents would load the whole map. This caused a perf regression (issue5713) and a regression with static http serving (issue5717). Making it lazy loaded again fixes both. Differential Revision: https://phab.mercurial-scm.org/D1253 diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -129,7 +129,7 @@ class dirstate(object): def _map(self): '''Return the dirstate contents as a map from filename to (state, mode, size, time).''' - self._read() + self._map = dirstatemap(self._ui, self._opener, self._root) return self._map @property @@ -353,10 +353,6 @@ class dirstate(object): f.discard() raise - def _read(self): - self._map = dirstatemap(self._ui, self._opener, self._root) - self._map.read() - def invalidate(self): '''Causes the next access to reread the dirstate. @@ -1201,14 +1197,24 @@ class dirstatemap(object): self._root = root self._filename = 'dirstate' - self._map = {} - self.copymap = {} self._parents = None self._dirtyparents = False # for consistent view between _pl() and _read() invocations self._pendingmode = None + @propertycache + def _map(self): + self._map = {} + self.read() + return self._map + + @propertycache + def copymap(self): + self.copymap = {} + self._map + return self.copymap + def clear(self): self._map = {} self.copymap = {} @@ -1388,7 +1394,7 @@ class dirstatemap(object): @propertycache def identity(self): - self.read() + self._map return self.identity @propertycache