##// END OF EJS Templates
store: cache the `files()` return for store entries...
marmoute -
r51524:b59e0a4f default
parent child Browse files
Show More
@@ -475,6 +475,7 b' class SimpleStoreEntry(BaseStoreEntry):'
475 _entry_path = attr.ib()
475 _entry_path = attr.ib()
476 _is_volatile = attr.ib(default=False)
476 _is_volatile = attr.ib(default=False)
477 _file_size = attr.ib(default=None)
477 _file_size = attr.ib(default=None)
478 _files = attr.ib(default=None)
478
479
479 def __init__(
480 def __init__(
480 self,
481 self,
@@ -486,15 +487,18 b' class SimpleStoreEntry(BaseStoreEntry):'
486 self._entry_path = entry_path
487 self._entry_path = entry_path
487 self._is_volatile = is_volatile
488 self._is_volatile = is_volatile
488 self._file_size = file_size
489 self._file_size = file_size
490 self._files = None
489
491
490 def files(self):
492 def files(self):
491 return [
493 if self._files is None:
494 self._files = [
492 StoreFile(
495 StoreFile(
493 unencoded_path=self._entry_path,
496 unencoded_path=self._entry_path,
494 file_size=self._file_size,
497 file_size=self._file_size,
495 is_volatile=self._is_volatile,
498 is_volatile=self._is_volatile,
496 )
499 )
497 ]
500 ]
501 return self._files
498
502
499
503
500 @attr.s(slots=True, init=False)
504 @attr.s(slots=True, init=False)
@@ -507,6 +511,7 b' class RevlogStoreEntry(BaseStoreEntry):'
507 target_id = attr.ib(default=None)
511 target_id = attr.ib(default=None)
508 _path_prefix = attr.ib(default=None)
512 _path_prefix = attr.ib(default=None)
509 _details = attr.ib(default=None)
513 _details = attr.ib(default=None)
514 _files = attr.ib(default=None)
510
515
511 def __init__(
516 def __init__(
512 self,
517 self,
@@ -521,6 +526,7 b' class RevlogStoreEntry(BaseStoreEntry):'
521 self._path_prefix = path_prefix
526 self._path_prefix = path_prefix
522 assert b'.i' in details, (path_prefix, details)
527 assert b'.i' in details, (path_prefix, details)
523 self._details = details
528 self._details = details
529 self._files = None
524
530
525 @property
531 @property
526 def is_changelog(self):
532 def is_changelog(self):
@@ -539,12 +545,13 b' class RevlogStoreEntry(BaseStoreEntry):'
539 return self._path_prefix + b'.i'
545 return self._path_prefix + b'.i'
540
546
541 def files(self):
547 def files(self):
542 files = []
548 if self._files is None:
549 self._files = []
543 for ext in sorted(self._details, key=_ext_key):
550 for ext in sorted(self._details, key=_ext_key):
544 path = self._path_prefix + ext
551 path = self._path_prefix + ext
545 data = self._details[ext]
552 data = self._details[ext]
546 files.append(StoreFile(unencoded_path=path, **data))
553 self._files.append(StoreFile(unencoded_path=path, **data))
547 return files
554 return self._files
548
555
549 def get_revlog_instance(self, repo):
556 def get_revlog_instance(self, repo):
550 """Obtain a revlog instance from this store entry
557 """Obtain a revlog instance from this store entry
General Comments 0
You need to be logged in to leave comments. Login now