[PATCH] Change standard streams mode to binary at hg startup
Patrick Mezard
pmezard at gmail.com
Sat Oct 27 20:55:33 UTC 2007
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1193509426 -7200
# Node ID d4398350521c12eb6caabdf0ae12abb3a1d50302
# Parent 7ceb740f2fefbfe9517c85416d7894499813e2c8
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.
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -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()
More information about the Mercurial-devel
mailing list