comparison mercurial/store.py @ 50476:2b2284cf949b

store: only access is_volatile information through the file object This make sure other code only access this information through the proper API, and it prepare for store entries to be able to agregate multiple files.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 08:57:45 +0200
parents 7d4d2a160cf5
children 4cbdfab6f812
comparison
equal deleted inserted replaced
50475:7d4d2a160cf5 50476:2b2284cf949b
458 """An entry in the store 458 """An entry in the store
459 459
460 This is returned by `store.walk` and represent some data in the store.""" 460 This is returned by `store.walk` and represent some data in the store."""
461 461
462 unencoded_path = attr.ib() 462 unencoded_path = attr.ib()
463 is_volatile = attr.ib(default=False) 463 _is_volatile = attr.ib(default=False)
464 _file_size = attr.ib(default=None) 464 _file_size = attr.ib(default=None)
465 465
466 def __init__( 466 def __init__(
467 self, 467 self,
468 unencoded_path, 468 unencoded_path,
469 is_volatile=False, 469 is_volatile=False,
470 file_size=None, 470 file_size=None,
471 ): 471 ):
472 self.unencoded_path = unencoded_path 472 self.unencoded_path = unencoded_path
473 self.is_volatile = is_volatile 473 self._is_volatile = is_volatile
474 self._file_size = file_size 474 self._file_size = file_size
475 475
476 def files(self): 476 def files(self):
477 return [ 477 return [
478 StoreFile( 478 StoreFile(
479 unencoded_path=self.unencoded_path, 479 unencoded_path=self.unencoded_path,
480 file_size=self._file_size, 480 file_size=self._file_size,
481 is_volatile=self.is_volatile, 481 is_volatile=self._is_volatile,
482 ) 482 )
483 ] 483 ]
484 484
485 485
486 @attr.s(slots=True, init=False) 486 @attr.s(slots=True, init=False)