comparison mercurial/store.py @ 50495:ed8cda1c18e1

store: rename `unencoded_path` to `entry_path` for StoreEntry This remove the ambiguity with StoreFile and make sure use code will be using the right API.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 09:02:59 +0200
parents b4953fad744e
children e50d1fe7ebb4
comparison
equal deleted inserted replaced
50494:b4953fad744e 50495:ed8cda1c18e1
462 class BaseStoreEntry: 462 class BaseStoreEntry:
463 """An entry in the store 463 """An entry in the store
464 464
465 This is returned by `store.walk` and represent some data in the store.""" 465 This is returned by `store.walk` and represent some data in the store."""
466 466
467 unencoded_path = attr.ib() 467 _entry_path = attr.ib()
468 _is_volatile = attr.ib(default=False) 468 _is_volatile = attr.ib(default=False)
469 _file_size = attr.ib(default=None) 469 _file_size = attr.ib(default=None)
470 470
471 def __init__( 471 def __init__(
472 self, 472 self,
473 unencoded_path, 473 entry_path,
474 is_volatile=False, 474 is_volatile=False,
475 file_size=None, 475 file_size=None,
476 ): 476 ):
477 self.unencoded_path = unencoded_path 477 self._entry_path = entry_path
478 self._is_volatile = is_volatile 478 self._is_volatile = is_volatile
479 self._file_size = file_size 479 self._file_size = file_size
480 480
481 def files(self): 481 def files(self):
482 return [ 482 return [
483 StoreFile( 483 StoreFile(
484 unencoded_path=self.unencoded_path, 484 unencoded_path=self._entry_path,
485 file_size=self._file_size, 485 file_size=self._file_size,
486 is_volatile=self._is_volatile, 486 is_volatile=self._is_volatile,
487 ) 487 )
488 ] 488 ]
489 489
504 target_id = attr.ib(default=None) 504 target_id = attr.ib(default=None)
505 is_revlog_main = attr.ib(default=None) 505 is_revlog_main = attr.ib(default=None)
506 506
507 def __init__( 507 def __init__(
508 self, 508 self,
509 unencoded_path, 509 entry_path,
510 revlog_type, 510 revlog_type,
511 target_id, 511 target_id,
512 is_revlog_main=False, 512 is_revlog_main=False,
513 is_volatile=False, 513 is_volatile=False,
514 file_size=None, 514 file_size=None,
515 ): 515 ):
516 super().__init__( 516 super().__init__(
517 unencoded_path=unencoded_path, 517 entry_path=entry_path,
518 is_volatile=is_volatile, 518 is_volatile=is_volatile,
519 file_size=file_size, 519 file_size=file_size,
520 ) 520 )
521 self.revlog_type = revlog_type 521 self.revlog_type = revlog_type
522 self.target_id = target_id 522 self.target_id = target_id
523 self.is_revlog_main = is_revlog_main 523 self.is_revlog_main = is_revlog_main
524 524
525 def main_file_path(self): 525 def main_file_path(self):
526 """unencoded path of the main revlog file""" 526 """unencoded path of the main revlog file"""
527 return self.unencoded_path 527 return self._entry_path
528 528
529 529
530 @attr.s(slots=True) 530 @attr.s(slots=True)
531 class StoreFile: 531 class StoreFile:
532 """a file matching an entry""" 532 """a file matching an entry"""
654 for revlog, details in _gather_revlog(files): 654 for revlog, details in _gather_revlog(files):
655 for ext, (t, s) in sorted(details.items()): 655 for ext, (t, s) in sorted(details.items()):
656 u = revlog + ext 656 u = revlog + ext
657 revlog_target_id = revlog.split(b'/', 1)[1] 657 revlog_target_id = revlog.split(b'/', 1)[1]
658 yield RevlogStoreEntry( 658 yield RevlogStoreEntry(
659 unencoded_path=u, 659 entry_path=u,
660 revlog_type=rl_type, 660 revlog_type=rl_type,
661 target_id=revlog_target_id, 661 target_id=revlog_target_id,
662 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), 662 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
663 is_volatile=bool(t & FILEFLAGS_VOLATILE), 663 is_volatile=bool(t & FILEFLAGS_VOLATILE),
664 file_size=s, 664 file_size=s,
677 elif u.startswith(b'00manifest'): 677 elif u.startswith(b'00manifest'):
678 name, ext = _split_revlog_ext(u) 678 name, ext = _split_revlog_ext(u)
679 manifestlogs[name][ext] = (t, s) 679 manifestlogs[name][ext] = (t, s)
680 else: 680 else:
681 yield SimpleStoreEntry( 681 yield SimpleStoreEntry(
682 unencoded_path=u, 682 entry_path=u,
683 is_volatile=bool(t & FILEFLAGS_VOLATILE), 683 is_volatile=bool(t & FILEFLAGS_VOLATILE),
684 file_size=s, 684 file_size=s,
685 ) 685 )
686 # yield manifest before changelog 686 # yield manifest before changelog
687 top_rl = [ 687 top_rl = [
695 # (keeping ordering so we get 00changelog.i last) 695 # (keeping ordering so we get 00changelog.i last)
696 key = lambda x: _ext_key(x[0]) 696 key = lambda x: _ext_key(x[0])
697 for ext, (t, s) in sorted(details.items(), key=key): 697 for ext, (t, s) in sorted(details.items(), key=key):
698 u = revlog + ext 698 u = revlog + ext
699 yield RevlogStoreEntry( 699 yield RevlogStoreEntry(
700 unencoded_path=u, 700 entry_path=u,
701 revlog_type=revlog_type, 701 revlog_type=revlog_type,
702 target_id=b'', 702 target_id=b'',
703 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), 703 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
704 is_volatile=bool(t & FILEFLAGS_VOLATILE), 704 is_volatile=bool(t & FILEFLAGS_VOLATILE),
705 file_size=s, 705 file_size=s,
993 # unreachable 993 # unreachable
994 assert False, revlog 994 assert False, revlog
995 for ext, t in sorted(details.items()): 995 for ext, t in sorted(details.items()):
996 f = revlog + ext 996 f = revlog + ext
997 entry = RevlogStoreEntry( 997 entry = RevlogStoreEntry(
998 unencoded_path=f, 998 entry_path=f,
999 revlog_type=rl_type, 999 revlog_type=rl_type,
1000 target_id=revlog_target_id, 1000 target_id=revlog_target_id,
1001 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), 1001 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
1002 is_volatile=bool(t & FILEFLAGS_VOLATILE), 1002 is_volatile=bool(t & FILEFLAGS_VOLATILE),
1003 ) 1003 )