comparison mercurial/util.py @ 35014: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 dacfcdd8b94e
children 25c543944bc0
comparison
equal deleted inserted replaced
35013:36507048da0f 35014:be6aa0cff8ea
928 return result 928 return result
929 929
930 def cachevalue(self, obj, value): 930 def cachevalue(self, obj, value):
931 # __dict__ assignment required to bypass __setattr__ (eg: repoview) 931 # __dict__ assignment required to bypass __setattr__ (eg: repoview)
932 obj.__dict__[self.name] = value 932 obj.__dict__[self.name] = value
933
934 def clearcachedproperty(obj, prop):
935 '''clear a cached property value, if one has been set'''
936 if prop in obj.__dict__:
937 del obj.__dict__[prop]
933 938
934 def pipefilter(s, cmd): 939 def pipefilter(s, cmd):
935 '''filter string S through command CMD, returning its output''' 940 '''filter string S through command CMD, returning its output'''
936 p = subprocess.Popen(cmd, shell=True, close_fds=closefds, 941 p = subprocess.Popen(cmd, shell=True, close_fds=closefds,
937 stdin=subprocess.PIPE, stdout=subprocess.PIPE) 942 stdin=subprocess.PIPE, stdout=subprocess.PIPE)