gclient: setdep writes binary for windows newline support
This fixes an issue on Windows where running `gclient setdep` would convert the DEPS file from LF to CRLF line endings.
From the python 2.7 docs:
" On Windows, 'b' appended to the mode opens the file in binary mode, so there are also modes like 'rb', 'wb', and 'r+b'. Python on Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written. "
- https://docs.python.org/2.7/tutorial/inputoutput.html#reading-and-writing-files
Change-Id: I94183918789a8cdd4aa655db4b3dadfaae23d13a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2067477
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: John Emau <John.Emau@microsoft.com>
diff --git a/gclient.py b/gclient.py
index 128d334..c347fcb 100755
--- a/gclient.py
+++ b/gclient.py
@@ -2981,8 +2981,8 @@
else:
gclient_eval.SetRevision(local_scope, name, value)
- with open(options.deps_file, 'w') as f:
- f.write(gclient_eval.RenderDEPSFile(local_scope))
+ with open(options.deps_file, 'wb') as f:
+ f.write(gclient_eval.RenderDEPSFile(local_scope).encode('utf-8'))
@metrics.collector.collect_metrics('gclient verify')