# HG changeset patch # User Pierre-Yves David # Date 2023-05-15 06:57:14 # Node ID c37450a5f1dc5cf015313c0a0c06d98b4e97db39 # Parent 5a2fb64d38b2386e42eeeac753eb22107d44b623 store: have custom init for entries class This will get useful to add special processing later in this series. diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -453,7 +453,7 @@ FILETYPE_FILELOG_OTHER = FILEFLAGS_FILEL FILETYPE_OTHER = FILEFLAGS_OTHER -@attr.s(slots=True) +@attr.s(slots=True, init=False) class BaseStoreEntry: """An entry in the store @@ -463,6 +463,16 @@ class BaseStoreEntry: is_volatile = attr.ib(default=False) file_size = attr.ib(default=None) + def __init__( + self, + unencoded_path, + is_volatile=False, + file_size=None, + ): + self.unencoded_path = unencoded_path + self.is_volatile = is_volatile + self.file_size = file_size + def files(self): return [ StoreFile( @@ -473,14 +483,14 @@ class BaseStoreEntry: ] -@attr.s(slots=True) +@attr.s(slots=True, init=False) class SimpleStoreEntry(BaseStoreEntry): """A generic entry in the store""" is_revlog = False -@attr.s(slots=True) +@attr.s(slots=True, init=False) class RevlogStoreEntry(BaseStoreEntry): """A revlog entry in the store""" @@ -488,6 +498,22 @@ class RevlogStoreEntry(BaseStoreEntry): revlog_type = attr.ib(default=None) is_revlog_main = attr.ib(default=None) + def __init__( + self, + unencoded_path, + revlog_type, + is_revlog_main=False, + is_volatile=False, + file_size=None, + ): + super().__init__( + unencoded_path=unencoded_path, + is_volatile=is_volatile, + file_size=file_size, + ) + self.revlog_type = revlog_type + self.is_revlog_main = is_revlog_main + @attr.s(slots=True) class StoreFile: