Robert Collins пишет:
> On Fri, 2008-02-29 at 10:07 +0000, Alexander Belchenko wrote:
>> Here the simple patch. Someone need to write test for it :-)
>>
>> === modified file 'bzrlib/builtins.py'
>> --- bzrlib/builtins.py 2008-02-25 07:28:29 +0000
>> +++ bzrlib/builtins.py 2008-02-29 10:06:23 +0000
>> @@ -3003,8 +3003,9 @@
>> mutter("%s", stored_location)
>> if stored_location is None:
>> raise errors.BzrCommandError("No location specified or remembered")
>> + terminal_encoding = self.outf.encoding or osutils.get_terminal_encoding()
>> display_url = urlutils.unescape_for_display(stored_location,
>> - self.outf.encoding)
>> + terminal_encoding)
>> self.outf.write("%s remembered location %s\n" % (verb_string,
>> display_url))
>> return stored_location
>
> perhaps we should set self.outf_encoding in the command infrastructure,
> and have a
> self.unescape_for_display(stored_location)
> which does
> return urlutils.unescape_for_display(url, self.outf_encoding)
The problem in this particular bug is the fact the 'merge' command uses
encoding = 'exact' so self.outf is actually sys.stdout and therefore is not encoded.
So for situation `bzr merge > /tmp/foo` sys.stdout.encoding is None.
And therefore self.outf.encoding is None. So the bug occurs.
Introducing self.outf_encoding in this situation is artificial.
Because it will be different value than sys.stdout.encoding.
Robert Collins пишет: builtins. py' BzrCommandError ("No location specified or remembered") get_terminal_ encoding( ) unescape_ for_display( stored_ location, for_display( stored_ location) unescape_ for_display( url, self.outf_encoding)
> On Fri, 2008-02-29 at 10:07 +0000, Alexander Belchenko wrote:
>> Here the simple patch. Someone need to write test for it :-)
>>
>> === modified file 'bzrlib/
>> --- bzrlib/builtins.py 2008-02-25 07:28:29 +0000
>> +++ bzrlib/builtins.py 2008-02-29 10:06:23 +0000
>> @@ -3003,8 +3003,9 @@
>> mutter("%s", stored_location)
>> if stored_location is None:
>> raise errors.
>> + terminal_encoding = self.outf.encoding or osutils.
>> display_url = urlutils.
>> - self.outf.encoding)
>> + terminal_encoding)
>> self.outf.write("%s remembered location %s\n" % (verb_string,
>> display_url))
>> return stored_location
>
> perhaps we should set self.outf_encoding in the command infrastructure,
> and have a
> self.unescape_
> which does
> return urlutils.
The problem in this particular bug is the fact the 'merge' command uses encoding.
encoding = 'exact' so self.outf is actually sys.stdout and therefore is not encoded.
So for situation `bzr merge > /tmp/foo` sys.stdout.encoding is None.
And therefore self.outf.encoding is None. So the bug occurs.
Introducing self.outf_encoding in this situation is artificial.
Because it will be different value than sys.stdout.
Actually my patch could be simplified even more:
=== modified file 'bzrlib/ builtins. py' BzrCommandError ("No location specified or remembered")
display_ url = urlutils. unescape_ for_display( stored_ location, get_terminal_ encoding( ))
self. outf.write( "%s remembered location %s\n" % (verb_string,
display_ url))
--- bzrlib/builtins.py 2008-02-25 07:28:29 +0000
+++ bzrlib/builtins.py 2008-02-29 11:38:47 +0000
@@ -3004,7 +3004,7 @@
if stored_location is None:
raise errors.
- self.outf.encoding)
+ osutils.
return stored_location