##// END OF EJS Templates
branchcache: move the header loading in a `_load_header` class method...
marmoute -
r52356:87b830e4 default
parent child Browse files
Show More
@@ -15,6 +15,7 b' from .node import ('
15 )
15 )
16
16
17 from typing import (
17 from typing import (
18 Any,
18 Callable,
19 Callable,
19 Dict,
20 Dict,
20 Iterable,
21 Iterable,
@@ -473,18 +474,11 b' class branchcache(_BaseBranchCache):'
473 try:
474 try:
474 f = repo.cachevfs(cls._filename(repo))
475 f = repo.cachevfs(cls._filename(repo))
475 lineiter = iter(f)
476 lineiter = iter(f)
476 cachekey = next(lineiter).rstrip(b'\n').split(b" ", 2)
477 init_kwargs = cls._load_header(repo, lineiter)
477 last, lrev = cachekey[:2]
478 last, lrev = bin(last), int(lrev)
479 filteredhash = None
480 if len(cachekey) > 2:
481 filteredhash = bin(cachekey[2])
482 bcache = cls(
478 bcache = cls(
483 repo,
479 repo,
484 tipnode=last,
485 tiprev=lrev,
486 filteredhash=filteredhash,
487 verify_node=True,
480 verify_node=True,
481 **init_kwargs,
488 )
482 )
489 if not bcache.validfor(repo):
483 if not bcache.validfor(repo):
490 # invalidate the cache
484 # invalidate the cache
@@ -509,6 +503,24 b' class branchcache(_BaseBranchCache):'
509
503
510 return bcache
504 return bcache
511
505
506 @classmethod
507 def _load_header(cls, repo, lineiter) -> "dict[str, Any]":
508 """parse the head of a branchmap file
509
510 return parameters to pass to a newly created class instance.
511 """
512 cachekey = next(lineiter).rstrip(b'\n').split(b" ", 2)
513 last, lrev = cachekey[:2]
514 last, lrev = bin(last), int(lrev)
515 filteredhash = None
516 if len(cachekey) > 2:
517 filteredhash = bin(cachekey[2])
518 return {
519 "tipnode": last,
520 "tiprev": lrev,
521 "filteredhash": filteredhash,
522 }
523
512 def _load_heads(self, repo, lineiter):
524 def _load_heads(self, repo, lineiter):
513 """fully loads the branchcache by reading from the file using the line
525 """fully loads the branchcache by reading from the file using the line
514 iterator passed"""
526 iterator passed"""
General Comments 0
You need to be logged in to leave comments. Login now