changeset 52939:b6f24a92b399

vfs: add a "buffering" argument to vfs mirroring the Python one This option let you control python buffering behavior on open file. We will use it to speed up the writing of data on disk during stream clone.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 30 Nov 2024 02:24:22 +0100
parents 34fa51c25112
children 7fc882f7fada
files mercurial/vfs.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/vfs.py	Fri Nov 29 22:22:54 2024 +0100
+++ b/mercurial/vfs.py	Sat Nov 30 02:24:22 2024 +0100
@@ -556,6 +556,7 @@
         checkambig: bool = False,
         auditpath: bool = True,
         makeparentdirs: bool = True,
+        buffering: int = -1,
     ) -> Any:  # TODO: should be BinaryIO if util.atomictempfile can be coersed
         """Open ``path`` file, which is relative to vfs root.
 
@@ -626,7 +627,7 @@
                         self._trustnlink = nlink > 1 or util.checknlink(f)
                     if nlink > 1 or not self._trustnlink:
                         util.rename(util.mktempcopy(f), f)
-        fp = util.posixfile(f, mode)
+        fp = util.posixfile(f, mode, buffering=buffering)
         if nlink == 0:
             self._fixfilemode(f)