Patchwork D1337: util: add util.clearcachedproperty

login
register
mail settings
Submitter phabricator
Date Nov. 10, 2017, 11:04 p.m.
Message ID <97a61e17dea19b7be92424caefe55a92@localhost.localdomain>
Download mbox | patch
Permalink /patch/25471/
State Not Applicable
Headers show

Comments

phabricator - Nov. 10, 2017, 11:04 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbe6aa0cff8ea: util: add util.clearcachedproperty (authored by mbthomas, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1337?vs=3337&id=3411

REVISION DETAIL
  https://phab.mercurial-scm.org/D1337

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




To: mbthomas, #hg-reviewers, indygreg, durin42
Cc: indygreg, mercurial-devel

Patch

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,