dirstate: remove _dirs property cache

Now that dirs is source of truthed on the dirstatemap, let's get rid of the
_dirs propertycache on the dirstate.

Differential Revision: https://phab.mercurial-scm.org/D982
This commit is contained in:
Durham Goode 2017-10-05 11:34:41 -07:00
parent 1b9b3caa47
commit e37fd6649b
2 changed files with 14 additions and 19 deletions

View File

@ -519,7 +519,7 @@ def perfdirs(ui, repo, **opts):
'a' in dirstate
def d():
dirstate.dirs()
del dirstate._dirs
del dirstate._map.dirs
timer(d)
fm.end()
@ -538,8 +538,8 @@ def perfdirstatedirs(ui, repo, **opts):
timer, fm = gettimer(ui, opts)
"a" in repo.dirstate
def d():
"a" in repo.dirstate._dirs
del repo.dirstate._dirs
"a" in repo.dirstate._map.dirs
del repo.dirstate._map.dirs
timer(d)
fm.end()
@ -562,7 +562,7 @@ def perfdirfoldmap(ui, repo, **opts):
def d():
dirstate._dirfoldmap.get('a')
del dirstate._dirfoldmap
del dirstate._dirs
del dirstate._map.dirs
timer(d)
fm.end()

View File

@ -136,7 +136,7 @@ class dirstate(object):
def _dirfoldmap(self):
f = {}
normcase = util.normcase
for name in self._dirs:
for name in self._map.dirs:
f[normcase(name)] = name
return f
@ -166,12 +166,8 @@ class dirstate(object):
def _pl(self):
return self._map.parents()
@propertycache
def _dirs(self):
return self._map.dirs()
def dirs(self):
return self._dirs
return self._map.dirs
@rootcache('.hgignore')
def _ignore(self):
@ -377,7 +373,7 @@ class dirstate(object):
check whether the dirstate has changed before rereading it.'''
for a in ("_map", "_dirfoldmap", "_branch",
"_dirs", "_ignore"):
"_ignore"):
if a in self.__dict__:
delattr(self, a)
self._lastnormaltime = 0
@ -405,8 +401,8 @@ class dirstate(object):
return self._map.copymap
def _droppath(self, f):
if self[f] not in "?r" and "_dirs" in self.__dict__:
self._dirs.delpath(f)
if self[f] not in "?r" and "dirs" in self._map.__dict__:
self._map.dirs.delpath(f)
if "filefoldmap" in self._map.__dict__:
normed = util.normcase(f)
@ -419,18 +415,18 @@ class dirstate(object):
oldstate = self[f]
if state == 'a' or oldstate == 'r':
scmutil.checkfilename(f)
if f in self._dirs:
if f in self._map.dirs:
raise error.Abort(_('directory %r already in dirstate') % f)
# shadows
for d in util.finddirs(f):
if d in self._dirs:
if d in self._map.dirs:
break
entry = self._map.get(d)
if entry is not None and entry[0] != 'r':
raise error.Abort(
_('file %r in dirstate clashes with %r') % (d, f))
if oldstate in "?r" and "_dirs" in self.__dict__:
self._dirs.addpath(f)
if oldstate in "?r" and "dirs" in self._map.__dict__:
self._map.dirs.addpath(f)
self._dirty = True
self._updatedfiles.add(f)
self._map[f] = dirstatetuple(state, mode, size, mtime)
@ -607,8 +603,6 @@ class dirstate(object):
def clear(self):
self._map = dirstatemap(self._ui, self._opener, self._root)
if "_dirs" in self.__dict__:
delattr(self, "_dirs")
self._map.setparents(nullid, nullid)
self._lastnormaltime = 0
self._updatedfiles.clear()
@ -1287,6 +1281,7 @@ class dirstatemap(object):
f['.'] = '.' # prevents useless util.fspath() invocation
return f
@propertycache
def dirs(self):
"""Returns a set-like object containing all the directories in the
current dirstate.