Avoid insertion/deletion of CRs on stdio during hg serve
authorolivier.maquelin@intel.com
Mon, 24 Oct 2005 14:34:48 -0700
changeset 1420 b32b3509c7ab
parent 1419 22041f754f4a
child 1421 a7631cf1326a
Avoid insertion/deletion of CRs on stdio during hg serve
mercurial/commands.py
mercurial/util.py
--- a/mercurial/commands.py	Fri Oct 21 00:15:55 2005 -0700
+++ b/mercurial/commands.py	Mon Oct 24 14:34:48 2005 -0700
@@ -1512,6 +1512,10 @@
         fin, fout = sys.stdin, sys.stdout
         sys.stdout = sys.stderr
 
+        # Prevent insertion/deletion of CRs
+        util.set_binary(fin)
+        util.set_binary(fout)
+
         def getarg():
             argline = fin.readline()[:-1]
             arg, l = argline.split()
--- a/mercurial/util.py	Fri Oct 21 00:15:55 2005 -0700
+++ b/mercurial/util.py	Mon Oct 24 14:34:48 2005 -0700
@@ -390,6 +390,7 @@
 
 # Platform specific variants
 if os.name == 'nt':
+    demandload(globals(), "msvcrt")
     nulldev = 'NUL:'
     
     try:
@@ -438,6 +439,9 @@
     def set_exec(f, mode):
         pass
 
+    def set_binary(fd):
+        msvcrt.setmode(fd.fileno(), os.O_BINARY)
+
     def pconvert(path):
         return path.replace("\\", "/")
 
@@ -484,6 +488,9 @@
         else:
             os.chmod(f, s & 0666)
 
+    def set_binary(fd):
+        pass
+
     def pconvert(path):
         return path