comparison mercurial/branchmap.py @ 51525:cebd96dee99a

branchcache: move the filename to a class attribute This prepare the introduction of more variant of cache.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 25 Feb 2024 20:40:37 +0100
parents 19b2736c8e45
children 47752632b4fc
comparison
equal deleted inserted replaced
51524:077d5a784c58 51525:cebd96dee99a
404 404
405 405
406 class branchcache(_BaseBranchCache): 406 class branchcache(_BaseBranchCache):
407 """Branchmap info for a local repo or repoview""" 407 """Branchmap info for a local repo or repoview"""
408 408
409 _base_filename = b"branch2"
410
409 def __init__( 411 def __init__(
410 self, 412 self,
411 repo: "localrepo.localrepository", 413 repo: "localrepo.localrepository",
412 entries: Union[ 414 entries: Union[
413 Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]] 415 Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]]
523 node = bin(node) 525 node = bin(node)
524 self._entries.setdefault(label, []).append(node) 526 self._entries.setdefault(label, []).append(node)
525 if state == b'c': 527 if state == b'c':
526 self._closednodes.add(node) 528 self._closednodes.add(node)
527 529
528 @staticmethod 530 @classmethod
529 def _filename(repo): 531 def _filename(cls, repo):
530 """name of a branchcache file for a given repo or repoview""" 532 """name of a branchcache file for a given repo or repoview"""
531 filename = b"branch2" 533 filename = cls._base_filename
532 if repo.filtername: 534 if repo.filtername:
533 filename = b'%s-%s' % (filename, repo.filtername) 535 filename = b'%s-%s' % (filename, repo.filtername)
534 return filename 536 return filename
535 537
536 def copy(self, repo): 538 def copy(self, repo):