comparison mercurial/localrepo.py @ 19846:9789670992d6 stable

repoview: have unfilteredpropertycache using the underlying cache A `unfilteredpropertycache` is a kind of `propertycache` used on `localrepo` to unsure it will always be run against unfiltered repo and stored only once. As the cached value is never stored in the repoview instance, the descriptor will always be called. Before this patch such calls always result in a call to the `__get__` method of the `propertycache` on the unfiltered repo. That was recomputing a new value on every access through a repoview. We can't prevent the repoview's `unfilteredpropertycache` to get called on every access. In that case the new code makes a standard attribute access to the property. If a value is cached it will be used. The `propertycache` test file have been augmented with test about this issue.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 30 Sep 2013 14:23:14 +0200
parents 14c91b18d798
children 57479e0d203d
comparison
equal deleted inserted replaced
19845:a1237a4b437d 19846:9789670992d6
37 37
38 class unfilteredpropertycache(propertycache): 38 class unfilteredpropertycache(propertycache):
39 """propertycache that apply to unfiltered repo only""" 39 """propertycache that apply to unfiltered repo only"""
40 40
41 def __get__(self, repo, type=None): 41 def __get__(self, repo, type=None):
42 return super(unfilteredpropertycache, self).__get__(repo.unfiltered()) 42 unfi = repo.unfiltered()
43 if unfi is repo:
44 return super(unfilteredpropertycache, self).__get__(unfi)
45 return getattr(unfi, self.name)
43 46
44 class filteredpropertycache(propertycache): 47 class filteredpropertycache(propertycache):
45 """propertycache that must take filtering in account""" 48 """propertycache that must take filtering in account"""
46 49
47 def cachevalue(self, obj, value): 50 def cachevalue(self, obj, value):