Mercurial > hg
changeset 48039: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 | 52018f8ef020 |
children | 7970895a21cb |
files | mercurial/localrepo.py tests/test-persistent-nodemap.t |
diffstat | 2 files changed, 26 insertions(+), 13 deletions(-) [+] |
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')
--- a/tests/test-persistent-nodemap.t Tue Sep 21 21:18:50 2021 +0200 +++ b/tests/test-persistent-nodemap.t Tue Sep 21 18:03:37 2021 +0200 @@ -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 (known-bad-output !) - Inconsistency: Revision 5007 found in nodemap is not in revlog indexi (known-bad-output !) $ hg -R ./race-repo log -G -r 'head()' o changeset: 5007:ac4a2abde241