[PATCH] ui.prompt(): let overridden write() method do it's job. Fix for color on win32.

Andrei Vermel andrei.vermel at gmail.com
Sun Jul 31 16:22:26 CDT 2011


On 01-Aug-11 12:23 AM, Mads Kiilerich wrote:
> Andrei Vermel wrote, On 07/31/2011 05:55 PM:
>> # HG changeset patch
>> # Parent b192d1dc6a848d08b757dd0f6fb2f4416acc170f
>> # User Andrei Vermel <avermel at mail.ru>
>> # Date 1312127463 -14400
>>
>> ui.prompt(): let overridden write() method do it's job. Fix for color 
>> on win32.
>>
>
> Will this also fix http://mercurial.selenic.com/bts/issue2887 ?
>
>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>> --- a/mercurial/ui.py
>> +++ b/mercurial/ui.py
>> @@ -540,7 +540,7 @@
>>          # instead of trying to emulate raw_input, swap our in/out
>>          # with sys.stdin/out
>>          old = sys.stdout, sys.stdin
>> -        sys.stdout, sys.stdin = self.fout, self.fin
>> +        sys.stdout, sys.stdin = self, self.fin
>
> Wouw. _That_ is duck typing. I don't think the ui class itself was 
> intended to implement the file protocol, so relying on it might be a 
> bit fragile.
>

On the other hand what else could raw_input() possibly use apart from 
the write method ?
I believe it is pretty much safe.

Andrei



More information about the Mercurial-devel mailing list