comparison mercurial/branchmap.py @ 51446:7f7086a42b2b

branchcache: have an explicit method to update the on disk cache Explicit is better and will give use more flexibility for future evolution of the storage.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 19 Jan 2024 11:30:10 +0100
parents 02e7d79edf62
children 3aba79ce52a9
comparison
equal deleted inserted replaced
51442:d2858d97af6c 51446:7f7086a42b2b
57 def __init__(self): 57 def __init__(self):
58 self._per_filter = {} 58 self._per_filter = {}
59 59
60 def __getitem__(self, repo): 60 def __getitem__(self, repo):
61 self.updatecache(repo) 61 self.updatecache(repo)
62 return self._per_filter[repo.filtername] 62 bcache = self._per_filter[repo.filtername]
63 return bcache
64
65 def update_disk(self, repo):
66 """ensure and up-to-date cache is (or will be) written on disk
67
68 The cache for this repository view is updated if needed and written on
69 disk.
70
71 If a transaction is in progress, the writing is schedule to transaction
72 close. See the `BranchMapCache.write_delayed` method.
73
74 This method exist independently of __getitem__ as it is sometime useful
75 to signal that we have no intend to use the data in memory yet.
76 """
77 self.updatecache(repo)
78 bcache = self._per_filter[repo.filtername]
79 bcache.write(repo)
63 80
64 def updatecache(self, repo): 81 def updatecache(self, repo):
65 """Update the cache for the given filtered view on a repository""" 82 """Update the cache for the given filtered view on a repository"""
66 # This can trigger updates for the caches for subsets of the filtered 83 # This can trigger updates for the caches for subsets of the filtered
67 # view, e.g. when there is no cache for this filtered view or the cache 84 # view, e.g. when there is no cache for this filtered view or the cache