# HG changeset patch # User olivier.maquelin@intel.com # Date 1130189688 25200 # Node ID b32b3509c7ab41a47f11834869a7805857627139 # Parent 22041f754f4a2a6bfb102f4ced5b305705134d01 Avoid insertion/deletion of CRs on stdio during hg serve diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1512,6 +1512,10 @@ def serve(ui, repo, **opts): 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() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -390,6 +390,7 @@ else: # Platform specific variants if os.name == 'nt': + demandload(globals(), "msvcrt") nulldev = 'NUL:' try: @@ -438,6 +439,9 @@ if os.name == 'nt': 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: else: os.chmod(f, s & 0666) + def set_binary(fd): + pass + def pconvert(path): return path