diff mercurial/store.py @ 52389:a260d326458f

stream: create a `e.preserve_volatiles` method directly on StoreEntry For cache, we will need an atomic operation that detect the file and preserve it, so we start by creating an API that make such atomic operation possible. We will actually make things atomic in the next changesets.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 02 Dec 2024 17:00:12 +0100
parents bd43465af568
children 3f0cf7bb3086
line wrap: on
line diff
--- a/mercurial/store.py	Mon Dec 02 16:01:00 2024 +0100
+++ b/mercurial/store.py	Mon Dec 02 17:00:12 2024 +0100
@@ -524,6 +524,16 @@
         assert vfs is not None
         return [f.get_stream(vfs, volatiles) for f in self.files()]
 
+    def preserve_volatiles(self, vfs, volatiles):
+        """Use a VolatileManager to preserve the state of any volatile file
+
+        This is useful for code that need a consistent view of the content like stream clone.
+        """
+        if self.maybe_volatile:
+            for f in self.files():
+                if f.is_volatile:
+                    volatiles(vfs.join(f.unencoded_path))
+
 
 @attr.s(slots=True, init=False)
 class SimpleStoreEntry(BaseStoreEntry):