Mercurial > hg-stable
changeset 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 | 3bdbbadddecc |
children | 774beab915fe |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Mon Jul 10 21:09:46 2017 -0700 +++ b/mercurial/localrepo.py Mon Jul 10 23:09:51 2017 +0900 @@ -104,6 +104,16 @@ def join(self, obj, fname): return obj.sjoin(fname) +def isfilecached(repo, name): + """check if a repo has already cached "name" filecache-ed property + + This returns (cachedobj-or-None, iscached) tuple. + """ + cacheentry = repo.unfiltered()._filecache.get(name, None) + if not cacheentry: + return None, False + return cacheentry.obj, True + class unfilteredpropertycache(util.propertycache): """propertycache that apply to unfiltered repo only"""