# HG changeset patch # User Pierre-Yves David # Date 1496853090 -3600 # 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 -r b8ff7d0ff361 -r 6f791ca70640 contrib/perf.py --- a/contrib/perf.py Thu Jun 08 23:23:37 2017 -0700 +++ b/contrib/perf.py Wed Jun 07 17:31:30 2017 +0100 @@ -357,6 +357,14 @@ # - 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 @@ 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 d(): repo.invalidatevolatilesets() if opts['clear_obsstore']: - _clearobsstore(repo) + clearfilecache(repo, 'obsstore') obsolete.getrevs(repo, name) return d @@ -1294,7 +1296,7 @@ def d(): repo.invalidatevolatilesets() if opts['clear_obsstore']: - _clearobsstore(repo) + clearfilecache(repo, 'obsstore') repoview.filterrevs(repo, name) return d