# HG changeset patch # User Pierre-Yves David # Date 2017-06-07 16:31:30 # Node ID 6f791ca70640cabb44cd46e75bb5d50b41c8be7b # Parent b8ff7d0ff36153e1dbb2c571ceeb35998a25423b perf: have a generic "clearstorecache" function There are multiple places where we will want to purge some store cache. So we promote the existing _clearobsstore function to a something reusable. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -357,6 +357,14 @@ def repocleartagscachefunc(repo): # - perf.py itself has been available since 1.1 (or eb240755386d) raise error.Abort(("tags API of this hg command is unknown")) +# utilities to clear cache + +def clearfilecache(repo, attrname): + unfi = repo.unfiltered() + if attrname in vars(unfi): + delattr(unfi, attrname) + unfi._filecache.pop(attrname, None) + # perf commands @command('perfwalk', formatteropts) @@ -1259,12 +1267,6 @@ def perfrevset(ui, repo, expr, clear=Fal timer(d) fm.end() -def _clearobsstore(repo): - unfi = repo.unfiltered() - if 'obsstore' in vars(unfi): - del unfi.obsstore - del unfi._filecache['obsstore'] - @command('perfvolatilesets', [('', 'clear-obsstore', False, 'drop obsstore between each call.'), ] + formatteropts) @@ -1279,7 +1281,7 @@ def perfvolatilesets(ui, repo, *names, * def d(): repo.invalidatevolatilesets() if opts['clear_obsstore']: - _clearobsstore(repo) + clearfilecache(repo, 'obsstore') obsolete.getrevs(repo, name) return d @@ -1294,7 +1296,7 @@ def perfvolatilesets(ui, repo, *names, * def d(): repo.invalidatevolatilesets() if opts['clear_obsstore']: - _clearobsstore(repo) + clearfilecache(repo, 'obsstore') repoview.filterrevs(repo, name) return d