D11482: changelog: also monitor `00changelog.n` when applicable (issue6554)
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Tue Sep 21 21:52:21 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This let the locarepo's file cache detect outdated nodemap docket and reload the
changelog after `localrepo.invalidate` when applicable.
REPOSITORY
rHG Mercurial
BRANCH
stable
REVISION DETAIL
https://phab.mercurial-scm.org/D11482
AFFECTED FILES
mercurial/localrepo.py
tests/test-persistent-nodemap.t
CHANGE DETAILS
diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -748,19 +748,19 @@
docket-details:
uid: 43c37dde
actual-tip: 5006
- tip-rev: 5005
- data-length: 121088
+ tip-rev: 5006
+ data-length: 121280
right ready to write, waiting for reader
right proceeding with writing its changelog index and nodemap
finalized changelog write
persisting changelog nodemap
- new data start at 121088
+ new data start at 121280
persisted changelog nodemap
docket-details:
uid: 43c37dde
actual-tip: 5007
tip-rev: 5007
- data-length: 121472
+ data-length: 121536
$ sh "$RUNTESTDIR"/testlib/wait-on-file 10 sync-files/reader-done
$ cat outputs/reader.txt
reader: reading changelog
@@ -768,7 +768,7 @@
reader: nodemap docket read
record-data-length: 121280
actual-data-length: 121280
- file-actual-length: 121472
+ file-actual-length: 121536
reader: changelog read
docket-details:
uid: 43c37dde
@@ -778,8 +778,6 @@
tip-rev: 5006
tip-node: 492901161367
node-rev: 5006
- error while checking revision: 18
- Inconsistency: Revision 5007 found in nodemap is not in revlog index
$ hg -R ./race-repo log -G -r 'head()'
o changeset: 5007:ac4a2abde241
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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')
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list