Patchwork [04,of,13] perf: introduce a function to fully "unload" a changelog

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 2:09 p.m.
Message ID <ba101026c80452a9f60b.1542982140@localhost.localdomain>
Download mbox | patch
Permalink /patch/36733/
State Accepted
Headers show

Comments

Boris Feld - Nov. 23, 2018, 2:09 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542951148 -3600
#      Fri Nov 23 06:32:28 2018 +0100
# Node ID ba101026c80452a9f60b3d574011c7e8773b5a4e
# Parent  56efcdd74aee7b45d2b85a7d414033cae6b465c7
# EXP-Topic perf-branchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ba101026c804
perf: introduce a function to fully "unload" a changelog

The function remove various attributes and caches related to changelog.

This is getting a common requirement.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -465,6 +465,12 @@  def clearfilecache(obj, attrname):
         delattr(obj, attrname)
     obj._filecache.pop(attrname, None)
 
+def clearchangelog(repo):
+    if repo is not repo.unfiltered():
+        object.__setattr__(repo, r'_clcachekey', None)
+        object.__setattr__(repo, r'_clcache', None)
+    clearfilecache(repo.unfiltered(), 'changelog')
+
 # perf commands
 
 @command(b'perfwalk', formatteropts)