D1337: util: add util.clearcachedproperty
mbthomas (Mark Thomas)
phabricator at mercurial-scm.org
Wed Nov 8 17:31:04 UTC 2017
mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This utility function allows clearing of the cached value set up
@propertycache, if there is one.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1337
AFFECTED FILES
mercurial/util.py
CHANGE DETAILS
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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,
To: mbthomas, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list