# HG changeset patch # User Pierre-Yves David # Date 1739895702 -3600 # Node ID e4ff37b5317c6e593dfd1e9af23ad80ef1553b9e # Parent 874c64e041b5c560cf53bb628f564caf9e0379ab stream-bundle: simple use of `mode` argument of `os.open` This argument have been around for a while and simplify the code. This is especially true as Windows does not have `os.fchmod` so we would have had to deal with this special case. 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