[PATCH] hgext/win32chcp: switches the console into an encoding actually used (issue2926)

Matt Mackall mpm at selenic.com
Fri Jul 29 13:43:57 CDT 2011


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 bet more is way too simple-minded to do
anything like and that the vast majority of console utilities are
completely clueless about codepages. It's also doubtful that it would be
in something like the C library startup code as it would tend to break
normal usage of chcp. Everything I can find suggests that codepages are
attached to consoles and not to processes:

http://msdn.microsoft.com/en-us/library/ms682064%28v=vs.85%29.aspx

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.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list