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