diff mercurial/util.py @ 18013:98c867ac1330

clfilter: add a propertycache that must be unfiltered Some of the localrepo property caches must be computed unfiltered and stored globally. Some others must see the filtered version and store data relative to the current filtering. This changeset introduces two classes `unfilteredpropertycache` and `filteredpropertycache` for this purpose. A new function `hasunfilteredcache` is introduced for unambiguous checking for cached values on unfiltered repos. A few tweaks are made to the property cache class to allow overriding the way the computed value is stored on the object. Some logic relative to _tagcaches is cleaned up in the process.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 08 Oct 2012 20:02:20 +0200
parents 4c29668ca316
children ddc0323db78b
line wrap: on
line diff
--- a/mercurial/util.py	Mon Oct 08 18:11:56 2012 +0200
+++ b/mercurial/util.py	Mon Oct 08 20:02:20 2012 +0200
@@ -244,9 +244,12 @@
         self.name = func.__name__
     def __get__(self, obj, type=None):
         result = self.func(obj)
-        setattr(obj, self.name, result)
+        self.cachevalue(obj, result)
         return result
 
+    def cachevalue(self, obj, value):
+        setattr(obj, self.name, value)
+
 def pipefilter(s, cmd):
     '''filter string S through command CMD, returning its output'''
     p = subprocess.Popen(cmd, shell=True, close_fds=closefds,