[PATCH 1 of 1] Avoid insertion/deletion of CRs on stdio during
hgserve
Maquelin, Olivier
olivier.maquelin at intel.com
Thu Sep 29 14:22:16 CDT 2005
Please disregard the previous patch and use the following instead. The
calls to set_binary() lacked a 'util.' in front of them (not sure how I
managed to miss that). Also, as was pointed out to me, it is better to
have the import of msvcrt fail outright (i.e. not have it in a
try/except block) instead of 'hg serve' failing in strange ways.
Sorry for the confusion.
-- Olivier
# HG changeset patch
# User olivier.maquelin at intel.com
# Node ID 3268840adafe77696b451a7757f21dd94b6c9413
# Parent ff20bb1d3d32a62bfc434f5b50cc6cbcf9e5b822
Avoid insertion/deletion of CRs on stdio during hg serve
diff -r ff20bb1d3d32 -r 3268840adafe mercurial/commands.py
--- a/mercurial/commands.py Thu Sep 29 12:00:28 2005 -0700
+++ b/mercurial/commands.py Thu Sep 29 12:10:30 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 3268840adafe mercurial/util.py
--- a/mercurial/util.py Thu Sep 29 12:00:28 2005 -0700
+++ b/mercurial/util.py Thu Sep 29 12:10:30 2005 -0700
@@ -369,6 +369,7 @@
# Platform specific variants
if os.name == 'nt':
+ import 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