Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 29373:36fbd72c2f39
scmutil: allow access to filecache descriptor on class
To make it easier to patch the wrapped function, make it possible to access the
filecache descriptor directly on the class (rather than have to use
ClassObject.__dict__['attributename']). Returning `self` when the first
argument to `__get__` is `None` makes the descriptor behave the same way
`property` objects do.
author | Martijn Pieters <mjpieters@fb.com> |
---|---|
date | Fri, 17 Jun 2016 20:06:09 +0100 |
parents | 37c7f9fb7040 |
children | 526b027b0130 |
comparison
equal
deleted
inserted
replaced
29372:0b5e9a625042 | 29373:36fbd72c2f39 |
---|---|
64 class repofilecache(scmutil.filecache): | 64 class repofilecache(scmutil.filecache): |
65 """All filecache usage on repo are done for logic that should be unfiltered | 65 """All filecache usage on repo are done for logic that should be unfiltered |
66 """ | 66 """ |
67 | 67 |
68 def __get__(self, repo, type=None): | 68 def __get__(self, repo, type=None): |
69 if repo is None: | |
70 return self | |
69 return super(repofilecache, self).__get__(repo.unfiltered(), type) | 71 return super(repofilecache, self).__get__(repo.unfiltered(), type) |
70 def __set__(self, repo, value): | 72 def __set__(self, repo, value): |
71 return super(repofilecache, self).__set__(repo.unfiltered(), value) | 73 return super(repofilecache, self).__set__(repo.unfiltered(), value) |
72 def __delete__(self, repo): | 74 def __delete__(self, repo): |
73 return super(repofilecache, self).__delete__(repo.unfiltered()) | 75 return super(repofilecache, self).__delete__(repo.unfiltered()) |