Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
18012:848c428bb5ee | 18013:98c867ac1330 |
---|---|
242 def __init__(self, func): | 242 def __init__(self, func): |
243 self.func = func | 243 self.func = func |
244 self.name = func.__name__ | 244 self.name = func.__name__ |
245 def __get__(self, obj, type=None): | 245 def __get__(self, obj, type=None): |
246 result = self.func(obj) | 246 result = self.func(obj) |
247 setattr(obj, self.name, result) | 247 self.cachevalue(obj, result) |
248 return result | 248 return result |
249 | |
250 def cachevalue(self, obj, value): | |
251 setattr(obj, self.name, value) | |
249 | 252 |
250 def pipefilter(s, cmd): | 253 def pipefilter(s, cmd): |
251 '''filter string S through command CMD, returning its output''' | 254 '''filter string S through command CMD, returning its output''' |
252 p = subprocess.Popen(cmd, shell=True, close_fds=closefds, | 255 p = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
253 stdin=subprocess.PIPE, stdout=subprocess.PIPE) | 256 stdin=subprocess.PIPE, stdout=subprocess.PIPE) |