EOL extension and patch.eol

Steve Borho steve at borho.org
Tue Dec 8 22:50:20 CST 2009


On Tue, Dec 8, 2009 at 10:13 PM, Mark Hammond <mhammond at skippinet.com.au> wrote:
> On 8/12/2009 8:44 PM, Martin Geisler wrote:
>>
>> Dirkjan Ochtman<dirkjan at ochtman.nl>  writes:
>>
>>> On Tue, Dec 8, 2009 at 02:19, Mark Hammond<skippy.hammond at gmail.com>
>>>  wrote:
>>>>
>>>> That said though, I wouldn't consider that to be a "blocker".  For my
>>>> interest though, does hg reopen stdout as binary?  Note that the script:
>>>
>>> I'm pretty sure we do.
>>
>> We do, the 'hg' script has these lines:
>>
>>   for fp in (sys.stdin, sys.stdout, sys.stderr):
>>       mercurial.util.set_binary(fp)
>
> So the next obvious question is: why?
>
> IIUC, this will only have any impact on Windows, and what it does there is
> to ensure output written by hg doesn't have native line endings.  eg:
>
> % hg log > log.out
>
> Should ideally generate a file that could be opened in any Windows editor
> (including notepad).

This was done to allow hg import, export, and other commands that read
or write stdin/stdout to work on Windows.  Long before we had even
patch.eol, we had to make these file descriptors binary for patching
to work at all.

By default Mercurial treats file contents as binary, and it expects
stdout to follow suit.  Otherwise commands like hg cat would be
utterly useless on Windows.

--
Steve Borho


More information about the Mercurial-devel mailing list