changeset 40683:d7936a9dad47

perf: make `clearfilecache` helper work with any object If the object is not a localrepo, it won't have an `unfiltered` method (and won't need one).
author Boris Feld <boris.feld@octobus.net>
date Mon, 19 Nov 2018 16:50:21 +0000
parents 4369c00a8ee1
children e6c9ef5e11a0
files contrib/perf.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Tue Nov 20 10:10:25 2018 +0000
+++ b/contrib/perf.py	Mon Nov 19 16:50:21 2018 +0000
@@ -457,11 +457,13 @@
 
 # utilities to clear cache
 
-def clearfilecache(repo, attrname):
-    unfi = repo.unfiltered()
-    if attrname in vars(unfi):
-        delattr(unfi, attrname)
-    unfi._filecache.pop(attrname, None)
+def clearfilecache(obj, attrname):
+    unfiltered = getattr(obj, 'unfiltered', None)
+    if unfiltered is not None:
+        obj = obj.unfiltered()
+    if attrname in vars(obj):
+        delattr(obj, attrname)
+    obj._filecache.pop(attrname, None)
 
 # perf commands