comparison mercurial/localrepo.py @ 33382:b107a7660f4e

localrepo: add isfilecached to check filecache-ed property is already cached isfilecached() encapsulates internal implementation of filecache-ed property. "name in repo.unfiltered().__dict__" or so can't be used for this purpose, because corresponded entry in __dict__ might be discarded by repo.invalidate(), repo.invalidatedirstate() or so (fsmonitor does so, for example). This patch makes isfilecached() return not only whether filecache-ed property is already cached, but also already cached value (or None), in order to avoid subsequent access to cached object via "repo.NAME", which prevents main Mercurial procedure after reposetup() from validating cache.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 10 Jul 2017 23:09:51 +0900
parents fb320398a21c
children 7e89bd0cfb86
comparison
equal deleted inserted replaced
33381:3bdbbadddecc 33382:b107a7660f4e
101 for path in paths: 101 for path in paths:
102 _cachedfiles.add((path, '')) 102 _cachedfiles.add((path, ''))
103 103
104 def join(self, obj, fname): 104 def join(self, obj, fname):
105 return obj.sjoin(fname) 105 return obj.sjoin(fname)
106
107 def isfilecached(repo, name):
108 """check if a repo has already cached "name" filecache-ed property
109
110 This returns (cachedobj-or-None, iscached) tuple.
111 """
112 cacheentry = repo.unfiltered()._filecache.get(name, None)
113 if not cacheentry:
114 return None, False
115 return cacheentry.obj, True
106 116
107 class unfilteredpropertycache(util.propertycache): 117 class unfilteredpropertycache(util.propertycache):
108 """propertycache that apply to unfiltered repo only""" 118 """propertycache that apply to unfiltered repo only"""
109 119
110 def __get__(self, repo, type=None): 120 def __get__(self, repo, type=None):