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.
--- 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)