D6711: branchheads: store wdir-dependent caches in wcache (issue6181)
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Mon Aug 5 21:08:09 EDT 2019
spectral updated this revision to Diff 16130.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6711?vs=16116&id=16130
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6711/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D6711
AFFECTED FILES
mercurial/branchmap.py
mercurial/utils/repoviewutil.py
tests/test-branchmap-cache.t
CHANGE DETAILS
diff --git a/tests/test-branchmap-cache.t b/tests/test-branchmap-cache.t
new file mode 100644
--- /dev/null
+++ b/tests/test-branchmap-cache.t
@@ -0,0 +1,38 @@
+ $ cat >> $HGRCPATH << EOF
+ > [extensions]
+ > share=
+ > [experimental]
+ > evolution=createmarkers
+ > EOF
+ $ hg init -q orig
+ $ cd orig
+ $ echo hi > foo
+ $ hg ci -qAm initial_rev0
+ $ echo "hi again" >> foo
+ $ hg ci -qAm "hi again rev1"
+ $ hg commit -q --amend -m "obsoleted 1, this is rev2"
+ $ cd ..
+ $ hg share -q orig other
+ $ cd other
+ $ hg co -qr 1 --hidden
+ updated to hidden changeset a3571a6d8234
+ (hidden revision 'a3571a6d8234' was rewritten as: 0444ce380f11)
+ $ cd ..
+
+Forcefully update the caches in each repo once; we're not using --debug since we
+know that these are going to update some/all of the caches, we don't need to
+know which.
+ $ hg -R orig debugupdatecache
+ $ hg -R other debugupdatecache
+
+The branchheads caches should not change just because we're accessing from a
+different repo each time. If they were stale, we'd get another line in the
+output per filtername that's stale.
+ $ hg -R orig debugupdatecache --debug
+ updating the branch cache
+ $ hg -R other debugupdatecache --debug
+ updating the branch cache
+ $ hg -R orig debugupdatecache --debug
+ updating the branch cache
+ $ hg -R other debugupdatecache --debug
+ updating the branch cache
diff --git a/mercurial/utils/repoviewutil.py b/mercurial/utils/repoviewutil.py
--- a/mercurial/utils/repoviewutil.py
+++ b/mercurial/utils/repoviewutil.py
@@ -26,3 +26,8 @@
# can be calculated from `subsettable` but `subsettable` is essentially
# constant, so we just hard-code it.
subsettableheads = frozenset({'visible-hidden', 'served.hidden'})
+
+# List of views that are potentially dependent upon wdir state (such as the
+# current parents of the working directory) and need to be kept in wcache
+# instead of cache.
+wdirdependent = frozenset(['served', 'visible', 'visible-hidden'])
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -221,7 +221,7 @@
def fromfile(cls, repo):
f = None
try:
- f = repo.cachevfs(cls._filename(repo))
+ f = cls._opencachefile(repo)
lineiter = iter(f)
cachekey = next(lineiter).rstrip('\n').split(" ", 2)
last, lrev = cachekey[:2]
@@ -271,12 +271,15 @@
self._closednodes.add(node)
@staticmethod
- def _filename(repo):
+ def _opencachefile(repo, *args, **kwargs):
"""name of a branchcache file for a given repo or repoview"""
filename = "branch2"
+ vfs = repo.cachevfs
if repo.filtername:
filename = '%s-%s' % (filename, repo.filtername)
- return filename
+ if repo.filtername in repoviewutil.wdirdependent:
+ vfs = repo.wcachevfs
+ return vfs(filename, *args, **kwargs)
def validfor(self, repo):
"""Is the cache content valid regarding a repo
@@ -335,7 +338,7 @@
def write(self, repo):
try:
- f = repo.cachevfs(self._filename(repo), "w", atomictemp=True)
+ f = self._opencachefile(repo, "w", atomictemp=True)
cachekey = [hex(self.tipnode), '%d' % self.tiprev]
if self.filteredhash is not None:
cachekey.append(hex(self.filteredhash))
To: spectral, #hg-reviewers
Cc: marmoute, mercurial-devel
More information about the Mercurial-devel
mailing list