# HG changeset patch # User Mark Thomas # Date 2017-11-08 17:18:18 # Node ID be6aa0cff8ea89b4b626e95e486ef59d15cbe7b4 # Parent 36507048da0ff79aca232705e3f25f292ddf660b 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 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -931,6 +931,11 @@ class propertycache(object): # __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,