changeset 50474:c37450a5f1dc

store: have custom init for entries class This will get useful to add special processing later in this series.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 08:57:14 +0200
parents 5a2fb64d38b2
children 7d4d2a160cf5
files mercurial/store.py
diffstat 1 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Mon May 15 08:56:56 2023 +0200
+++ b/mercurial/store.py	Mon May 15 08:57:14 2023 +0200
@@ -453,7 +453,7 @@
 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 @@
     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 @@
         ]
 
 
-@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 @@
     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: