[PATCH 4 of 8] perf: make `clearfilecache` helper work with any object
Boris Feld
boris.feld at octobus.net
Wed Nov 21 18:33:54 UTC 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1542646221 0
# Mon Nov 19 16:50:21 2018 +0000
# Node ID ea3a9f11bceef210118fc368908f4cfcd5a814fa
# Parent 73f19cded5865968e672a0e1d1b6aaaef2b77e18
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ea3a9f11bcee
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).
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -457,11 +457,13 @@ def repocleartagscachefunc(repo):
# 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
More information about the Mercurial-devel
mailing list