[PATCH 7 of 8 "] manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sat Mar 16 06:36:28 EDT 2019
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1552662463 0
# Fri Mar 15 15:07:43 2019 +0000
# Node ID 027c8ee15982b19da2adc5f116211ce5587e23f8
# Parent 81ba24a2f24106d17e0d865d4973a6228b6106a4
# EXP-Topic manifestcache
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 027c8ee15982
manifestcache: protect write with `wlock` instead of `lock`
The `wlock` is taken by both `update` and `commit` type operation. This would
help persisting the cache more aggressively.
An explicit test is introduced. However, we can already see the effect of this
change on earlier test output.
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1476,13 +1476,13 @@ def debugmanifestfulltextcache(ui, repo,
raise error.Abort(msg)
if opts.get(r'clear'):
- with repo.lock():
+ with repo.wlock():
cache = getcache()
cache.clear(clear_persisted_data=True)
return
if add:
- with repo.lock():
+ with repo.wlock():
m = repo.manifestlog
store = m.getstorage(b'')
for n in add:
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1435,11 +1435,11 @@ class manifestrevlog(object):
def _setupmanifestcachehooks(self, repo):
"""Persist the manifestfulltextcache on lock release"""
- if not util.safehasattr(repo, '_lockref'):
+ if not util.safehasattr(repo, '_wlockref'):
return
self._fulltextcache._opener = repo.cachevfs
- if repo._currentlock(repo._lockref) is None:
+ if repo._currentlock(repo._wlockref) is None:
return
reporef = weakref.ref(repo)
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -58,6 +58,7 @@ Ensure branchcache got copied over:
$ ls .hg/cache
branch2-served
+ manifestfulltextcache
rbc-names-v1
rbc-revs-v1
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -290,7 +290,7 @@ Update back to revision 12 in r4 should
1 r4/.hg/branch
2 r4/.hg/cache/branch2-base
2 r4/.hg/cache/branch2-served
- 2 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
+ 1 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
2 r4/.hg/cache/rbc-names-v1
2 r4/.hg/cache/rbc-revs-v1
1 r4/.hg/dirstate
diff --git a/tests/test-manifest.t b/tests/test-manifest.t
--- a/tests/test-manifest.t
+++ b/tests/test-manifest.t
@@ -106,7 +106,9 @@ Reminder of the manifest log content
Showing the content of the caches after the above operations
$ hg debugmanifestfulltextcache
- cache empty
+ cache contains 1 manifest entries, in order of most to least recent:
+ id: 1e01206b1d2f72bd55f2a33fa8ccad74144825b7, size 133 bytes
+ total cache data size 157 bytes, on-disk 157 bytes
(Clearing the cache in case of any content)
@@ -183,3 +185,19 @@ Commit should have the new node cached:
$ hg log -r 'ancestors(., 1)' --debug | grep 'manifest:'
manifest: 1:1e01206b1d2f72bd55f2a33fa8ccad74144825b7
manifest: 2:26b8653b67af8c1a0a0317c4ee8dac50a41fdb65
+
+hg update should warm the cache too
+
+(force dirstate check to avoid flackiness in manifest order)
+ $ hg debugrebuilddirstate
+
+ $ hg update 0
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ hg debugmanifestfulltextcache
+ cache contains 3 manifest entries, in order of most to least recent:
+ id: fce2a30dedad1eef4da95ca1dc0004157aa527cf, size 87 bytes
+ id: 26b8653b67af8c1a0a0317c4ee8dac50a41fdb65, size 133 bytes
+ id: 1e01206b1d2f72bd55f2a33fa8ccad74144825b7, size 133 bytes
+ total cache data size 425 bytes, on-disk 425 bytes
+ $ hg log -r '0' --debug | grep 'manifest:'
+ manifest: 0:fce2a30dedad1eef4da95ca1dc0004157aa527cf
More information about the Mercurial-devel
mailing list