[PATCH 1 of 1] Avoid insertion/deletion of CRs on stdio during hg serve

Maquelin, Olivier olivier.maquelin at intel.com
Thu Sep 29 13:43:36 CDT 2005


# HG changeset patch
# User olivier.maquelin at intel.com
# Node ID ef617d6079ee53d09f1af18863a892fa3805cecd
# Parent  51ac9a79f3e5bda2c734106a7a221376f1331066
Avoid insertion/deletion of CRs on stdio during hg serve

diff -r 51ac9a79f3e5 -r ef617d6079ee mercurial/commands.py
--- a/mercurial/commands.py	Tue Sep 27 18:30:54 2005 -0700
+++ b/mercurial/commands.py	Thu Sep 29 11:37:19 2005 -0700
@@ -1486,6 +1486,10 @@
     if opts["stdio"]:
         fin, fout = sys.stdin, sys.stdout
         sys.stdout = sys.stderr
+
+        # Prevent insertion/deletion of CRs
+        set_binary(fin)
+        set_binary(fout)
 
         def getarg():
             argline = fin.readline()[:-1]
diff -r 51ac9a79f3e5 -r ef617d6079ee mercurial/util.py
--- a/mercurial/util.py	Tue Sep 27 18:30:54 2005 -0700
+++ b/mercurial/util.py	Thu Sep 29 11:37:19 2005 -0700
@@ -408,6 +408,13 @@
     def set_exec(f, mode):
         pass
 
+    def set_binary(fd):
+        try:
+            import msvcrt
+            msvcrt.setmode(fd.fileno(), os.O_BINARY)
+        except ImportError:
+            pass
+
     def pconvert(path):
         return path.replace("\\", "/")
 
@@ -453,6 +460,9 @@
             os.chmod(f, s | (s & 0444) >> 2 & ~umask)
         else:
             os.chmod(f, s & 0666)
+
+    def set_binary(fd):
+        pass
 
     def pconvert(path):
         return path


More information about the Mercurial mailing list