Patchwork [4,of,8] caches: call 'repo.updatecache()' in 'repo.destroyed()'

mail settings
Submitter Pierre-Yves David
Date May 2, 2017, 11:43 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/20363/
State Accepted
Headers show


Pierre-Yves David - May 2, 2017, 11:43 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1493744758 -7200
#      Tue May 02 19:05:58 2017 +0200
# Branch stable
# Node ID a3dc2747c4e0eea11d6fce071d444e93bcde50c3
# Parent  a98df6dbb264bd89889cd43f04bc6ddf6f9df142
# EXP-Topic obscache
# Available At
#              hg pull -r a3dc2747c4e0
caches: call 'repo.updatecache()' in 'repo.destroyed()'

Regenerating the cache after a 'strip' or a 'rollback' is useful. So we call the
generic cache warming function as other caches than just branchmap will be
updated there in the future.

To do so, we have to make 'repo.updatecache()' able to take no arguments. In
such cases, we reload all caches.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1260,14 +1260,20 @@  class localrepository(object):
         return 0
-    def updatecaches(self, tr):
-        """warm appropriate caches after a transaction closed"""
-        if tr.hookargs.get('source') == 'strip':
+    def updatecaches(self, tr=None):
+        """warm appropriate caches
+        If this function is called after a transaction closed. The transaction
+        will be available in the 'tr' argument. This can be used to selectively
+        update caches relevant to the changes in that transaction.
+        """
+        if tr is not None and tr.hookargs.get('source') == 'strip':
             # During strip, many caches are invalid but
             # later call to `destroyed` will refresh them.
-        if tr.changes['revs']:
+        if tr is None or tr.changes['revs']:
+            # updating the unfiltered branchmap should refresh all the others,
     def invalidatecaches(self):
@@ -1858,10 +1864,8 @@  class localrepository(object):
-        # update the 'served' branch cache to help read only server process
-        # Thanks to branchcache collaboration this is done from the nearest
-        # filtered subset and it is expected to be fast.
-        branchmap.updatecache(self.filtered('served'))
+        # refresh all repository caches
+        self.updatecaches()
         # Ensure the persistent tag cache is updated.  Doing it now
         # means that the tag cache only has to worry about destroyed