changeset 18014:a39fe76c4c65

clfilter: ensure that filecache on localrepo is unfiltered All filecache usage on repo is for logic that should be unfiltered. The caches should be common to all filtered instances, and computation must be done unfiltered. A dedicated storecache subclass is created for this purpose.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 08 Oct 2012 19:34:04 +0200
parents 98c867ac1330
children 42f56a0418b3 74912fe3d718
files mercurial/bundlerepo.py mercurial/localrepo.py
diffstat 2 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Mon Oct 08 20:02:20 2012 +0200
+++ b/mercurial/bundlerepo.py	Mon Oct 08 19:34:04 2012 +0200
@@ -214,7 +214,7 @@
         # dict with the mapping 'filename' -> position in the bundle
         self.bundlefilespos = {}
 
-    @util.propertycache
+    @localrepo.unfilteredpropertycache
     def changelog(self):
         # consume the header if it exists
         self.bundle.changelogheader()
@@ -222,7 +222,7 @@
         self.manstart = self.bundle.tell()
         return c
 
-    @util.propertycache
+    @localrepo.unfilteredpropertycache
     def manifest(self):
         self.bundle.seek(self.manstart)
         # consume the header if it exists
@@ -231,12 +231,12 @@
         self.filestart = self.bundle.tell()
         return m
 
-    @util.propertycache
+    @localrepo.unfilteredpropertycache
     def manstart(self):
         self.changelog
         return self.manstart
 
-    @util.propertycache
+    @localrepo.unfilteredpropertycache
     def filestart(self):
         self.manifest
         return self.filestart
--- a/mercurial/localrepo.py	Mon Oct 08 20:02:20 2012 +0200
+++ b/mercurial/localrepo.py	Mon Oct 08 19:34:04 2012 +0200
@@ -18,7 +18,18 @@
 propertycache = util.propertycache
 filecache = scmutil.filecache
 
-class storecache(filecache):
+class repofilecache(filecache):
+    """All filecache usage on repo are done for logic that should be unfiltered
+    """
+
+    def __get__(self, repo, type=None):
+        return super(repofilecache, self).__get__(repo.unfiltered(), type)
+    def __set__(self, repo, value):
+        return super(repofilecache, self).__set__(repo.unfiltered(), value)
+    def __delete__(self, repo):
+        return super(repofilecache, self).__delete__(repo.unfiltered())
+
+class storecache(repofilecache):
     """filecache for files in the store"""
     def join(self, obj, fname):
         return obj.sjoin(fname)
@@ -292,11 +303,11 @@
         Intended to be ovewritten by filtered repo."""
         return self
 
-    @filecache('bookmarks')
+    @repofilecache('bookmarks')
     def _bookmarks(self):
         return bookmarks.bmstore(self)
 
-    @filecache('bookmarks.current')
+    @repofilecache('bookmarks.current')
     def _bookmarkcurrent(self):
         return bookmarks.readcurrent(self)
 
@@ -355,7 +366,7 @@
     def manifest(self):
         return manifest.manifest(self.sopener)
 
-    @filecache('dirstate')
+    @repofilecache('dirstate')
     def dirstate(self):
         warned = [0]
         def validate(node):