diff mercurial/store.py @ 50514:0925eaf09c8b

store: make `walk` return an entry for obsolescence if requested so Instead of having dedicated code in the streamclone code, we should have the store deal with advertising the data it contains.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 21 May 2023 02:29:33 +0200
parents 5a62d56e3955
children e1ee6910f6bc
line wrap: on
line diff
--- a/mercurial/store.py	Sun May 21 02:16:24 2023 +0200
+++ b/mercurial/store.py	Sun May 21 02:29:33 2023 +0200
@@ -685,13 +685,22 @@
                     details=file_details,
                 )
 
-    def top_entries(self, phase=False) -> Generator[BaseStoreEntry, None, None]:
+    def top_entries(
+        self, phase=False, obsolescence=False
+    ) -> Generator[BaseStoreEntry, None, None]:
         if phase and self.vfs.exists(b'phaseroots'):
             yield SimpleStoreEntry(
                 entry_path=b'phaseroots',
                 is_volatile=True,
             )
 
+        if obsolescence and self.vfs.exists(b'obsstore'):
+            # XXX if we had the file size it could be non-volatile
+            yield SimpleStoreEntry(
+                entry_path=b'obsstore',
+                is_volatile=True,
+            )
+
         files = reversed(self._walk(b'', False))
 
         changelogs = collections.defaultdict(dict)
@@ -733,7 +742,7 @@
                 )
 
     def walk(
-        self, matcher=None, phase=False
+        self, matcher=None, phase=False, obsolescence=False
     ) -> Generator[BaseStoreEntry, None, None]:
         """return files related to data storage (ie: revlogs)
 
@@ -745,7 +754,7 @@
         # yield data files first
         for x in self.data_entries(matcher):
             yield x
-        for x in self.top_entries(phase=phase):
+        for x in self.top_entries(phase=phase, obsolescence=obsolescence):
             yield x
 
     def copylist(self):