diff -r 874c64e041b5 -r e4ff37b5317c mercurial/streamclone.py --- a/mercurial/streamclone.py Fri Feb 07 17:42:43 2025 -0500 +++ b/mercurial/streamclone.py Tue Feb 18 17:21:42 2025 +0100 @@ -1545,10 +1545,11 @@ def _write_files(info: Iterable[FileInfoT]): """write files from parsed data""" for path, mode, data in info: - fd = os.open(path, os.O_WRONLY | os.O_CREAT) + if mode is None: + fd = os.open(path, os.O_WRONLY | os.O_CREAT) + else: + fd = os.open(path, os.O_WRONLY | os.O_CREAT, mode=mode) try: - if mode is not None: - os.fchmod(fd, mode) for chunk in data: written = os.write(fd, chunk) # write missing pieces if the write was interrupted