changeset 52043:e308439339e2

stream: rename TempCopyManager to VolatileManager We are going to be more subtle in our management of volatile file, so use a more semantic name.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 14 Oct 2024 15:11:49 +0200
parents f9f41b3dcb64
children 0ad269e24075
files mercurial/store.py mercurial/streamclone.py
diffstat 2 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Mon Oct 14 12:12:34 2024 -0400
+++ b/mercurial/store.py	Mon Oct 14 15:11:49 2024 +0200
@@ -477,7 +477,7 @@
     def has_size(self):
         return self._file_size is not None
 
-    def get_stream(self, vfs, copies):
+    def get_stream(self, vfs, volatiles):
         """return data "stream" information for this file
 
         (unencoded_file_path, content_iterator, content_size)
@@ -485,7 +485,7 @@
         size = self.file_size(None)
 
         def get_stream():
-            actual_path = copies[vfs.join(self.unencoded_path)]
+            actual_path = volatiles[vfs.join(self.unencoded_path)]
             with open(actual_path, 'rb') as fp:
                 yield None  # ready to stream
                 if size <= 65536:
@@ -513,7 +513,7 @@
         self,
         repo=None,
         vfs=None,
-        copies=None,
+        volatiles=None,
         max_changeset=None,
         preserve_file_count=False,
     ):
@@ -522,7 +522,7 @@
         return [(unencoded_file_path, content_iterator, content_size), …]
         """
         assert vfs is not None
-        return [f.get_stream(vfs, copies) for f in self.files()]
+        return [f.get_stream(vfs, volatiles) for f in self.files()]
 
 
 @attr.s(slots=True, init=False)
@@ -632,7 +632,7 @@
         self,
         repo=None,
         vfs=None,
-        copies=None,
+        volatiles=None,
         max_changeset=None,
         preserve_file_count=False,
     ):
@@ -648,13 +648,13 @@
             return super().get_streams(
                 repo=repo,
                 vfs=vfs,
-                copies=copies,
+                volatiles=volatiles,
                 max_changeset=max_changeset,
                 preserve_file_count=preserve_file_count,
             )
         elif not preserve_file_count:
             stream = [
-                f.get_stream(vfs, copies)
+                f.get_stream(vfs, volatiles)
                 for f in self.files()
                 if not f.unencoded_path.endswith((b'.i', b'.d'))
             ]
@@ -668,7 +668,7 @@
             name_to_size[f.unencoded_path] = f.file_size(None)
 
         stream = [
-            f.get_stream(vfs, copies)
+            f.get_stream(vfs, volatiles)
             for f in self.files()
             if not f.unencoded_path.endswith(b'.i')
         ]
--- a/mercurial/streamclone.py	Mon Oct 14 12:12:34 2024 -0400
+++ b/mercurial/streamclone.py	Mon Oct 14 15:11:49 2024 +0200
@@ -566,7 +566,7 @@
     return (src, name, ftype, copy(vfsmap[src].join(name)))
 
 
-class TempCopyManager:
+class VolatileManager:
     """Manage temporary backup of volatile file during stream clone
 
     This should be used as a Python context, the copies will be discarded when
@@ -659,12 +659,12 @@
         _(b'bundle'), total=totalfilesize, unit=_(b'bytes')
     )
     progress.update(0)
-    with TempCopyManager() as copy, progress:
-        # create a copy of volatile files
+    with VolatileManager() as volatiles, progress:
+        # make sure we preserve volatile files
         for k, vfs, e in entries:
             for f in e.files():
                 if f.is_volatile:
-                    copy(vfs.join(f.unencoded_path))
+                    volatiles(vfs.join(f.unencoded_path))
         # the first yield release the lock on the repository
         yield file_count, totalfilesize
         totalbytecount = 0
@@ -673,7 +673,7 @@
             entry_streams = e.get_streams(
                 repo=repo,
                 vfs=vfs,
-                copies=copy,
+                volatiles=volatiles,
                 max_changeset=max_linkrev,
                 preserve_file_count=True,
             )
@@ -722,15 +722,15 @@
         unit=_(b'entry'),
     )
     progress.update(0)
-    with TempCopyManager() as copy, progress:
-        # create a copy of volatile files
+    with VolatileManager() as volatiles, progress:
+        # make sure we preserve volatile files
         for k, vfs, e in entries:
             if e.maybe_volatile:
                 for f in e.files():
                     if f.is_volatile:
                         # record the expected size under lock
                         f.file_size(vfs)
-                        copy(vfs.join(f.unencoded_path))
+                        volatiles(vfs.join(f.unencoded_path))
         # the first yield release the lock on the repository
         yield None
 
@@ -740,7 +740,7 @@
             entry_streams = e.get_streams(
                 repo=repo,
                 vfs=vfs,
-                copies=copy,
+                volatiles=volatiles,
                 max_changeset=max_linkrev,
             )
             yield util.uvarintencode(len(entry_streams))