Buffering in mercurial with redirected output

Sergey Antonov sergant_ at mail.ru
Tue Jan 4 15:54:51 CST 2011


On 04.01.2011 23:40, Greg Ward wrote:
> On Tue, Jan 4, 2011 at 2:56 AM, Sergey Antonov<sergant_ at mail.ru>  wrote:
>> I'm using a mercurial command line client with redirected output to make a
>> GUI around some of mercurial commands.
>>
>> The problem I have is that the output is buffered and I don't get any output
>> from the command until it ends or until there is more output then the buffer
>> length.
>>
>> For example, when I use it for commands: incoming, outgoing, pull, push, I
>> would like to show every line as soon as it is available.
>>
>> Is there a way to disable buffering of redirected output ?
>
> You could invoke hg with "python -u".  Or set PYTHONUNBUFFERED=1.
> "man python" for details.

I've tried to set PYTHONUNBUFFERED=1 environment variable, but this 
doesn't work for me. I'm using a binary package of mercurial hg.exe 
v1.7.3 on Windows.

For testing purpose I use 'incoming' command on large repository. The 
first few lines should be drawn instantly:

comparing with remote-url
searching for changes

but I still don't get any output until the command ends or the output is 
larger than buffer length.

Also, I checked with Procmon tool, that PYTHONUNBUFFERED variable is set 
in hg.exe process, while it is running.

Actually, I use .Net API to run external process with mercurial client 
(Process class with asynchronous read from redirected ouput). Maybe it 
adds another layer of buffering output. I will check that.

Thanks.

-- 
Sergey Antonov
sergant_ at mail.ru


More information about the Mercurial-devel mailing list