[MERGE] [#196881] Fix merge redirection when remembered location used
Alexander Belchenko
bialix at ukr.net
Fri Mar 7 01:37:53 GMT 2008
This patch is already merged but it has hidden the bug inside and will wait
to blow up when someone will merge with remembered non-ascii local path.
Especially these lines:
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 29.02.2008 17:53:56
+++ bzrlib/builtins.py 04.03.2008 18:53:03
@@ -3008,10 +3008,8 @@
mutter("%s", stored_location)
if stored_location is None:
raise errors.BzrCommandError("No location specified or remembered")
- display_url = urlutils.unescape_for_display(stored_location,
- self.outf.encoding)
- self.outf.write("%s remembered location %s\n" % (verb_string,
- display_url))
+ display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
+ note(u"%s remembered location %s", verb_string, display_url)
return stored_location
urlutils.unescape_for_display returns plain string in given encoding (utf-8 here)
and then converted to unicode by note(u"%s remembered ...
So it will blow up with UnicodeDecodeError one day.
Also note that comment for urlutils.unescape_for_display claims that this
function returns "A unicode string which can be safely encoded into the specified encoding"
but it's not true. Because here is actual code for local urls:
path = local_path_from_url(url)
path.encode(encoding)
return path
IMO my version of bugfix was safer for unicode paths.
Ian Clatworthy пишет:
> This fixes https://bugs.launchpad.net/bzr/+bug/196881. Thanks to
> Alexander, John and Aaron for feedback on this. This patch includes
> John's code changes together with an entry in NEWS.
>
> Ian C.
>
More information about the bazaar
mailing list