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

Boris Feld boris.feld at octobus.net
Fri Nov 23 09:09:00 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at 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.

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)


More information about the Mercurial-devel mailing list