# HG changeset patch # User Durham Goode # Date 2017-10-05 18:34:41 # Node ID e8a89ed7ce96b0b8f665e030939059fc1dab4a50 # Parent 014bd2a555c8fb2b83891d4e57df55fd3382cde2 dirstate: move the _dirfoldmap to dirstatemap Now that dirstatemap is the source of truth for the list of directories, let's move _dirfoldmap on to it. This pattern of moving cached variables onto the dirstate map makes it easier to invalidate them, as seen by how the cache invalidation functions are slowly shrinking to just be recreating the dirstatemap instance. Differential Revision: https://phab.mercurial-scm.org/D983 diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -560,8 +560,8 @@ def perfdirfoldmap(ui, repo, **opts): dirstate = repo.dirstate 'a' in dirstate def d(): - dirstate._dirfoldmap.get('a') - del dirstate._dirfoldmap + dirstate._map.dirfoldmap.get('a') + del dirstate._map.dirfoldmap del dirstate._map.dirs timer(d) fm.end() diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -132,14 +132,6 @@ class dirstate(object): self._read() return self._map - @propertycache - def _dirfoldmap(self): - f = {} - normcase = util.normcase - for name in self._map.dirs: - f[normcase(name)] = name - return f - @property def _sparsematcher(self): """The matcher for the sparse checkout. @@ -372,8 +364,7 @@ class dirstate(object): rereads the dirstate. Use localrepo.invalidatedirstate() if you want to check whether the dirstate has changed before rereading it.''' - for a in ("_map", "_dirfoldmap", "_branch", - "_ignore"): + for a in ("_map", "_branch", "_ignore"): if a in self.__dict__: delattr(self, a) self._lastnormaltime = 0 @@ -568,7 +559,7 @@ class dirstate(object): normed = util.normcase(path) folded = self._map.filefoldmap.get(normed, None) if folded is None: - folded = self._dirfoldmap.get(normed, None) + folded = self._map.dirfoldmap.get(normed, None) if folded is None: if isknown: folded = path @@ -576,7 +567,7 @@ class dirstate(object): # store discovered result in dirfoldmap so that future # normalizefile calls don't start matching directories folded = self._discoverpath(path, normed, ignoremissing, exists, - self._dirfoldmap) + self._map.dirfoldmap) return folded def normalize(self, path, isknown=False, ignoremissing=False): @@ -875,7 +866,7 @@ class dirstate(object): if len(paths) > 1: for path in paths: folded = self._discoverpath(path, norm, True, None, - self._dirfoldmap) + self._map.dirfoldmap) if path != folded: results[path] = None @@ -1396,3 +1387,10 @@ class dirstatemap(object): self.read() return self.identity + @propertycache + def dirfoldmap(self): + f = {} + normcase = util.normcase + for name in self.dirs: + f[normcase(name)] = name + return f