Mercurial > hg-stable
changeset 23502:ced3ecfc2e57
repoview: allow methods on the proxy class to be replaced
It doesn't seem to be a common idiom for repo instances, but the status() method
is replaced in largefiles' purge() override. Since __setattr__ is implemented
in repoview to setattr() on the unfiltered repo, the replacement method wouldn't
get called unless it was invoked with the unfiltered repo, because the filtered
repo remains unchanged.
Since this doesn't seem to be commonly used, I didn't bother to filter out
methods that perhaps shouldn't be replaced, such as changelog().
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 07 Dec 2014 10:52:56 -0500 |
parents | b46876c94a93 |
children | ca54fb3d71ce |
files | mercurial/repoview.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/repoview.py Wed Nov 26 23:23:33 2014 -0800 +++ b/mercurial/repoview.py Sun Dec 07 10:52:56 2014 -0500 @@ -6,6 +6,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +import types import copy import error import phases @@ -310,6 +311,10 @@ return getattr(self._unfilteredrepo, attr) def __setattr__(self, attr, value): + # Allow method replacement on filtered repos, like status() in + # largefiles' purge override + if type(value) == types.FunctionType: + object.__setattr__(self, attr, value) return setattr(self._unfilteredrepo, attr, value) def __delattr__(self, attr):