Change standard streams mode to binary at hg startup
authorPatrick Mezard <pmezard@gmail.com>
Sat, 10 Nov 2007 21:30:59 +0100
changeset 5531 a3fe91b4f6eb
parent 5530 b0ff52ec9b52
child 5532 40a06e39f010
Change standard streams mode to binary at hg startup Standard streams are expected to operate in binary mode everywhere, especially with archive, cat, diff and export commands. Rewriting these to separate informational output from binary content is complicated to do and to maintain, nonwithstanding mode switching reliability. Changing all output mode to binary should not have much impact on Windows were stream processing tools are barely used and usually cope with unix style endings. Streams mode being process wide, the switch is performed in the startup script to avoid polluting existing API users who may have solved this issue already or ignored it at least for the mercurial part.
hg
--- a/hg	Sat Nov 10 21:30:43 2007 +0100
+++ b/hg	Sat Nov 10 21:30:59 2007 +0100
@@ -10,5 +10,11 @@
 # enable importing on demand to reduce startup time
 from mercurial import demandimport; demandimport.enable()
 
+import sys
+import mercurial.util
 import mercurial.dispatch
+
+for fp in (sys.stdin, sys.stdout, sys.stderr):
+    mercurial.util.set_binary(fp)
+
 mercurial.dispatch.run()