diff mercurial/localrepo.py @ 47888:c094e829e848 stable

changelog: also monitor `00changelog.n` when applicable (issue6554) This let the locarepo's file cache detect outdated nodemap docket and reload the changelog after `localrepo.invalidate` when applicable. Differential Revision: https://phab.mercurial-scm.org/D11482
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 21 Sep 2021 18:03:37 +0200
parents 2813d406b036
children 7970895a21cb
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Sep 21 21:18:50 2021 +0200
+++ b/mercurial/localrepo.py	Tue Sep 21 18:03:37 2021 +0200
@@ -144,6 +144,21 @@
         return obj.sjoin(fname)
 
 
+class changelogcache(storecache):
+    """filecache for the changelog"""
+
+    def __init__(self):
+        super(changelogcache, self).__init__()
+        _cachedfiles.add((b'00changelog.i', b''))
+        _cachedfiles.add((b'00changelog.n', b''))
+
+    def tracked_paths(self, obj):
+        paths = [self.join(obj, b'00changelog.i')]
+        if obj.store.opener.options.get(b'persistent-nodemap', False):
+            paths.append(self.join(obj, b'00changelog.n'))
+        return paths
+
+
 class mixedrepostorecache(_basefilecache):
     """filecache for a mix files in .hg/store and outside"""
 
@@ -1673,13 +1688,13 @@
     def obsstore(self):
         return obsolete.makestore(self.ui, self)
 
-    @storecache(b'00changelog.i')
-    def changelog(self):
+    @changelogcache()
+    def changelog(repo):
         # load dirstate before changelog to avoid race see issue6303
-        self.dirstate.prefetch_parents()
-        return self.store.changelog(
-            txnutil.mayhavepending(self.root),
-            concurrencychecker=revlogchecker.get_checker(self.ui, b'changelog'),
+        repo.dirstate.prefetch_parents()
+        return repo.store.changelog(
+            txnutil.mayhavepending(repo.root),
+            concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
         )
 
     @storecache(b'00manifest.i')