dirstate: do not build the dirfoldmap if _dirs isn't set

Summary:
On EdenFS on Windows (case insensitive), _dirs isn't set, but touching it will
lead to the rest of the dirstate code trying to use it. For instance, removing
a file in the dirstate would try to remove it from _dirs, which would fail as
_dirs is expected to be empty on EdenFS.

Reviewed By: fanzeyi

Differential Revision: D23067897

fbshipit-source-id: 0e0d4aa6457c31d572a2aebc87f0a2fa7215001f
This commit is contained in:
Xavier Deguillard 2020-08-13 08:24:26 -07:00 committed by Facebook GitHub Bot
parent a8e3912cdf
commit e6ddfb4e71

View File

@ -1608,6 +1608,12 @@ class dirstatemap(object):
@util.propertycache
def _dirs(self):
# type: () -> bindings.dirs.dirs
"""
Build a set of directories present in the dirstate.
Some dirstate implementation (eden for instance), don't support this,
and it's thus a good idea to test if "_dirs" is in self.__dict__.
"""
return util.dirs((p for (p, s) in pycompat.iteritems(self._map) if s[0] != "r"))
@util.propertycache
@ -1739,7 +1745,8 @@ class dirstatemap(object):
# type: () -> Dict[str, str]
f = {}
normcase = util.normcase
# pyre-fixme[16]: Iterable has no attribute __next__
for name in self._dirs:
f[normcase(name)] = name
if "_dirs" in self.__dict__:
# pyre-fixme[16]: Iterable has no attribute __next__
for name in self._dirs:
f[normcase(name)] = name
return f