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

Idan Kamara idankk86 at gmail.com
Tue Sep 10 15:06:55 CDT 2013


On Tue, Sep 10, 2013 at 2:43 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

> # 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
>

This whole cached+proxy attribute hell desperately needs a bunch of unit
tests.


>
> 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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130910/77c3496b/attachment.html>


More information about the Mercurial-devel mailing list