[PATCH 1 of 2 V2] log: flush stdout/err for the first log entries

Matt Mackall mpm at selenic.com
Mon Sep 28 18:15:22 CDT 2015


On Sat, 2015-09-26 at 17:03 +0900, Yuya Nishihara wrote:
> So we want line-buffering for first 50 lines?
> 
> I've timed it with line-buffered stdout. It's slightly slower than fully-
> buffered io, but perhaps we don't care it if we use the pager.

No, we don't.

> +    # XXX hack to initialize buffering mode of stdout to the default of tty
> +    # (i.e. IOLBF) before dup2()
> +    sys.stdout.write('\r')
> +    sys.stdout.flush()

Hmm, this is probably the mysterious behavior that was thwarting my own
attempts to do this. Probably a bit too hacky.

> +    # or call setvbuf() explicitly (needs this if stdout is /dev/null)
> +    #import _chgutil
> +    #_chgutil.setfilebufmode(sys.stdout, _chgutil.IOLBF)

How does this work?

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list