[Updated] D12128: branchmap: stop writing cache for uncommitted data
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Feb 2 10:54:17 UTC 2022
Closed by commit rHG8e5effbf52d0: branchmap: stop writing cache for uncommitted data (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12128?vs=32024&id=32031
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12128/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12128
AFFECTED FILES
mercurial/branchmap.py
mercurial/localrepo.py
tests/test-branches.t
CHANGE DETAILS
diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -1336,7 +1336,5 @@
abort: pretxnclose hook failed
[40]
$ cat branchmap-update-02/.hg/cache/branch2-served
- 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 (missing-correct-output !)
- 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A (missing-correct-output !)
- 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 (known-bad-output !)
- 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A (known-bad-output !)
+ 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
+ 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2830,6 +2830,8 @@
self.ui.debug(b'updating the branch cache\n')
self.filtered(b'served').branchmap()
self.filtered(b'served.hidden').branchmap()
+ # flush all possibly delayed write.
+ self._branchcaches.write_delayed(self)
if repository.CACHE_CHANGELOG_CACHE in caches:
self.changelog.update_caches(transaction=tr)
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -149,6 +149,13 @@
def clear(self):
self._per_filter.clear()
+ def write_delayed(self, repo):
+ unfi = repo.unfiltered()
+ for filtername, cache in self._per_filter.items():
+ if cache._delayed:
+ repo = unfi.filtered(filtername)
+ cache.write(repo)
+
def _unknownnode(node):
"""raises ValueError when branchcache found a node which does not exists"""
@@ -199,6 +206,7 @@
has a given node or not. If it's not provided, we assume that every node
we have exists in changelog"""
self._repo = repo
+ self._delayed = False
if tipnode is None:
self.tipnode = repo.nullid
else:
@@ -403,6 +411,13 @@
)
def write(self, repo):
+ tr = repo.currenttransaction()
+ if not getattr(tr, 'finalized', True):
+ # Avoid premature writing.
+ #
+ # (The cache warming setup by localrepo will update the file later.)
+ self._delayed = True
+ return
try:
f = repo.cachevfs(self._filename(repo), b"w", atomictemp=True)
cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
@@ -427,6 +442,7 @@
len(self._entries),
nodecount,
)
+ self._delayed = False
except (IOError, OSError, error.Abort) as inst:
# Abort may be raised by read only opener, so log and continue
repo.ui.debug(
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220202/8f29ed3c/attachment-0002.html>
More information about the Mercurial-patches
mailing list