[PATCH] hgext/win32chcp: switches the console into an encoding actually used (issue2926)
Andrei Polushin
polushin at gmail.com
Fri Jul 29 16:52:19 CDT 2011
30.07.2011 1:43, Matt Mackall wrote:
> On Sat, 2011-07-30 at 00:25 +0700, Andrei Polushin wrote:
>> One problem still remains: `hg log | more' doesn't produce readable output on
>> OEM console, because `more' resets the encoding itself, and it happens at an
>> arbitrary time.
>
> I'm skeptical of this theory. [...]
> I think it's much more likely to be a race of some form. What I suspect
> happens here is that there are three processes involved:
>
> hg more console window
> start hg
> start more
> set codepage
> (send message to console)
> start writing text
> start reading text
> start printing
> (write directly to screen)
> receives chcp
> screws up display
>
> I think introducing some delays in various places would test this
> theory.
Your scenario seems to be wrong, because I'm getting some readable text at
the beginning, while all further characters are unreadable.
But you are right in a sense that it's a race condition. When I remove
atexit.register(restoreconsoleencoding), it starts working just fine,
I see readable characters until the end.
But the console codepage still needs to be restored somehow. It should be
restored when `more' terminates, because `hg' terminates too early, while
`more' is still running.
--
Andrei Polushin
More information about the Mercurial-devel
mailing list