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

Maquelin, Olivier olivier.maquelin at intel.com
Thu Sep 29 15:53:20 CDT 2005


Yet another update of this patch. The msvcrt module is now imported
using the demandload mechanism, as suggested by Bryan O'Sullivan.

-- Olivier


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

diff -r ff20bb1d3d32 -r 5fa1ee1417af mercurial/commands.py
--- a/mercurial/commands.py	Thu Sep 29 12:00:28 2005 -0700
+++ b/mercurial/commands.py	Thu Sep 29 13:13:51 2005 -0700
@@ -1486,6 +1486,10 @@
     if opts["stdio"]:
         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]
diff -r ff20bb1d3d32 -r 5fa1ee1417af mercurial/util.py
--- a/mercurial/util.py	Thu Sep 29 12:00:28 2005 -0700
+++ b/mercurial/util.py	Thu Sep 29 13:13:51 2005 -0700
@@ -369,6 +369,7 @@
 
 # Platform specific variants
 if os.name == 'nt':
+    demandload(globals(), "msvcrt")
     nulldev = 'NUL:'
 
     rcpath = (r'c:\mercurial\mercurial.ini',
@@ -407,6 +408,9 @@
 
     def set_exec(f, mode):
         pass
+
+    def set_binary(fd):
+        msvcrt.setmode(fd.fileno(), os.O_BINARY)
 
     def pconvert(path):
         return path.replace("\\", "/")
@@ -453,6 +457,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