Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 51516:fd30c4301929
branchcache: stop storing a repository instance on the cache altogether
We did not really needed it and we do not needs it anymore at all. So lets make
things simpler for consistency and garbage collecting and stop storing it
altogether.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 19 Feb 2024 11:59:56 +0100 |
parents | 3aba79ce52a9 |
children | 5515876173ba |
comparison
equal
deleted
inserted
replaced
51515:3aba79ce52a9 | 51516:fd30c4301929 |
---|---|
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 bcache = self._per_filter[repo.filtername] | 62 bcache = self._per_filter[repo.filtername] |
63 assert bcache._repo.filtername == repo.filtername, ( | 63 assert bcache._filtername == repo.filtername, ( |
64 bcache._repo.filtername, | 64 bcache._filtername, |
65 repo.filtername, | 65 repo.filtername, |
66 ) | 66 ) |
67 return bcache | 67 return bcache |
68 | 68 |
69 def update_disk(self, repo): | 69 def update_disk(self, repo): |
78 This method exist independently of __getitem__ as it is sometime useful | 78 This method exist independently of __getitem__ as it is sometime useful |
79 to signal that we have no intend to use the data in memory yet. | 79 to signal that we have no intend to use the data in memory yet. |
80 """ | 80 """ |
81 self.updatecache(repo) | 81 self.updatecache(repo) |
82 bcache = self._per_filter[repo.filtername] | 82 bcache = self._per_filter[repo.filtername] |
83 assert bcache._repo.filtername == repo.filtername, ( | 83 assert bcache._filtername == repo.filtername, ( |
84 bcache._repo.filtername, | 84 bcache._filtername, |
85 repo.filtername, | 85 repo.filtername, |
86 ) | 86 ) |
87 bcache.write(repo) | 87 bcache.write(repo) |
88 | 88 |
89 def updatecache(self, repo): | 89 def updatecache(self, repo): |
218 hasnode: Optional[Callable[[bytes], bool]] = None, | 218 hasnode: Optional[Callable[[bytes], bool]] = None, |
219 ) -> None: | 219 ) -> None: |
220 """hasnode is a function which can be used to verify whether changelog | 220 """hasnode is a function which can be used to verify whether changelog |
221 has a given node or not. If it's not provided, we assume that every node | 221 has a given node or not. If it's not provided, we assume that every node |
222 we have exists in changelog""" | 222 we have exists in changelog""" |
223 self._repo = repo | 223 self._filtername = repo.filtername |
224 self._delayed = False | 224 self._delayed = False |
225 if tipnode is None: | 225 if tipnode is None: |
226 self.tipnode = repo.nullid | 226 self.tipnode = repo.nullid |
227 else: | 227 else: |
228 self.tipnode = tipnode | 228 self.tipnode = tipnode |
433 self.filteredhash, | 433 self.filteredhash, |
434 self._closednodes, | 434 self._closednodes, |
435 ) | 435 ) |
436 | 436 |
437 def write(self, repo): | 437 def write(self, repo): |
438 assert self._repo.filtername == repo.filtername, ( | 438 assert self._filtername == repo.filtername, ( |
439 self._repo.filtername, | 439 self._filtername, |
440 repo.filtername, | 440 repo.filtername, |
441 ) | 441 ) |
442 tr = repo.currenttransaction() | 442 tr = repo.currenttransaction() |
443 if not getattr(tr, 'finalized', True): | 443 if not getattr(tr, 'finalized', True): |
444 # Avoid premature writing. | 444 # Avoid premature writing. |
481 def update(self, repo, revgen): | 481 def update(self, repo, revgen): |
482 """Given a branchhead cache, self, that may have extra nodes or be | 482 """Given a branchhead cache, self, that may have extra nodes or be |
483 missing heads, and a generator of nodes that are strictly a superset of | 483 missing heads, and a generator of nodes that are strictly a superset of |
484 heads missing, this function updates self to be correct. | 484 heads missing, this function updates self to be correct. |
485 """ | 485 """ |
486 assert self._repo.filtername == repo.filtername, ( | 486 assert self._filtername == repo.filtername, ( |
487 self._repo.filtername, | 487 self._filtername, |
488 repo.filtername, | 488 repo.filtername, |
489 ) | 489 ) |
490 starttime = util.timer() | 490 starttime = util.timer() |
491 cl = repo.changelog | 491 cl = repo.changelog |
492 # collect new branch entries | 492 # collect new branch entries |