--- a/mercurial/vfs.py Mon Jan 20 12:41:20 2025 +0100
+++ b/mercurial/vfs.py Wed Jan 29 02:17:33 2025 +0100
@@ -25,6 +25,7 @@
List,
MutableMapping,
Optional,
+ Set,
Tuple,
Type,
TypeVar,
@@ -86,6 +87,9 @@
# by the Rust code
rust_compatible = True
+ # createmode is always available on subclasses
+ createmode: int
+
# TODO: type return, which is util.posixfile wrapped by a proxy
@abc.abstractmethod
def __call__(self, path: bytes, mode: bytes = b'rb', **kwargs) -> Any:
@@ -456,6 +460,23 @@
def register_file(self, path: bytes) -> None:
"""generic hook point to lets fncache steer its stew"""
+ def prepare_streamed_file(
+ self, path: bytes, known_directories: Set[bytes]
+ ) -> None:
+ """make sure we are ready to write a file from a stream clone
+
+ The "known_directories" variable is here to avoid trying to create the
+ same directories over and over during a stream clone. It will be
+ updated by this function.
+ """
+ self._auditpath(path, b'wb')
+ self.register_file(path)
+ real_path = self.join(path)
+ dirname, basename = util.split(real_path)
+ if dirname not in known_directories:
+ util.makedirs(dirname, self.createmode, True)
+ known_directories.add(dirname)
+
class vfs(abstractvfs):
"""Operate files relative to a base directory