Mercurial > hg-stable
changeset 35053:be6aa0cff8ea
util: add util.clearcachedproperty
This utility function allows clearing of the cached value set up
@propertycache, if there is one.
Differential Revision: https://phab.mercurial-scm.org/D1337
author | Mark Thomas <mbthomas@fb.com> |
---|---|
date | Wed, 08 Nov 2017 09:18:18 -0800 |
parents | 36507048da0f |
children | ecede5263adb |
files | mercurial/util.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Fri Nov 10 17:12:04 2017 -0500 +++ b/mercurial/util.py Wed Nov 08 09:18:18 2017 -0800 @@ -931,6 +931,11 @@ # __dict__ assignment required to bypass __setattr__ (eg: repoview) obj.__dict__[self.name] = value +def clearcachedproperty(obj, prop): + '''clear a cached property value, if one has been set''' + if prop in obj.__dict__: + del obj.__dict__[prop] + def pipefilter(s, cmd): '''filter string S through command CMD, returning its output''' p = subprocess.Popen(cmd, shell=True, close_fds=closefds,