[PATCH 1 of 2 STABLE] repoview: make propertycache.setcache compatible

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 10 11:43:08 UTC 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1378806515 -7200
#      Tue Sep 10 11:48:35 2013 +0200
# Branch stable
# Node ID accf46f194e4f5aee5d48c5c910ad169dd419458
# Parent  fd4f612f7cb6413940d4cf2052334cd23f60e042
repoview: make propertycache.setcache compatible

Propertycache used standard attribute assignment. In the repoview case, this
assignment was forwarded to the unfiltered repo. This result in:
(1) unfiltered repo got a potentially wrong cache value,
(2) repoview never reused the cached value.

This patch replaces the standard attribute assignment by an assignment to
`objc.__dict__` which will bypass the `repoview.__setattr__`. This will not
affects other `propertycache` users and it is actually closer to the semantic we
need.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -277,11 +277,12 @@ class propertycache(object):
         result = self.func(obj)
         self.cachevalue(obj, result)
         return result
 
     def cachevalue(self, obj, value):
-        setattr(obj, self.name, value)
+        # __dict__ assigment required to bypass __setattr__ (eg: repoview)
+        obj.__dict__[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,
                          stdin=subprocess.PIPE, stdout=subprocess.PIPE)


More information about the Mercurial-devel mailing list