Changeset View
Changeset View
Standalone View
Standalone View
mercurial/store.py
Show First 20 Lines • Show All 700 Lines • ▼ Show 20 Line(s) | class _fncachevfs(vfsmod.proxyvfs): | ||||
def __call__(self, path, mode=b'r', *args, **kw): | def __call__(self, path, mode=b'r', *args, **kw): | ||||
encoded = self.encode(path) | encoded = self.encode(path) | ||||
if mode not in (b'r', b'rb') and ( | if mode not in (b'r', b'rb') and ( | ||||
path.startswith(b'data/') or path.startswith(b'meta/') | path.startswith(b'data/') or path.startswith(b'meta/') | ||||
): | ): | ||||
# do not trigger a fncache load when adding a file that already is | # do not trigger a fncache load when adding a file that already is | ||||
# known to exist. | # known to exist. | ||||
notload = self.fncache.entries is None and self.vfs.exists(encoded) | notload = self.fncache.entries is None and self.vfs.exists(encoded) | ||||
if notload and b'a' in mode and not self.vfs.stat(encoded).st_size: | if notload and b'r+' in mode and not self.vfs.stat(encoded).st_size: | ||||
# when appending to an existing file, if the file has size zero, | # when appending to an existing file, if the file has size zero, | ||||
# it should be considered as missing. Such zero-size files are | # it should be considered as missing. Such zero-size files are | ||||
# the result of truncation when a transaction is aborted. | # the result of truncation when a transaction is aborted. | ||||
notload = False | notload = False | ||||
if not notload: | if not notload: | ||||
self.fncache.add(path) | self.fncache.add(path) | ||||
return self.vfs(encoded, mode, *args, **kw) | return self.vfs(encoded, mode, *args, **kw) | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |