Rev 4217: Fix Tree.get_symlink_target to decode from the disk encoding to get a unicode encoded string. in http://people.ubuntu.com/~robertc/baz2.0/pending/commit-uses-ric
Robert Collins
robertc at robertcollins.net
Tue Mar 31 01:12:26 BST 2009
At http://people.ubuntu.com/~robertc/baz2.0/pending/commit-uses-ric
------------------------------------------------------------
revno: 4217
revision-id: robertc at robertcollins.net-20090331001210-fufeq2heozx9jne0
parent: pqm at pqm.ubuntu.com-20090330055028-lhmncpzf7ebkd2yc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-uses-ric
timestamp: Tue 2009-03-31 11:12:10 +1100
message:
Fix Tree.get_symlink_target to decode from the disk encoding to get a unicode encoded string.
=== modified file 'NEWS'
--- a/NEWS 2009-03-30 05:50:28 +0000
+++ b/NEWS 2009-03-31 00:12:10 +0000
@@ -194,6 +194,10 @@
module documentation for ``bzrlib.smart.request`` for details.
(Andrew Bennetts, Robert Collins)
+* ``Tree.get_symlink_target`` now always returns a unicode string result
+ or None. Previously it would return the bytes from reading the link
+ which could be in any arbitrary encoding. (Robert Collins)
+
Testing
*******
=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_diff.py 2009-03-31 00:12:10 +0000
@@ -704,7 +704,7 @@
r'--- olddir/oldfile.*\n\+\+\+ newdir/newfile.*\n\@\@ -1,1 \+0,0'
' \@\@\n-old\n\n')
self.assertContainsRe(self.differ.to_file.getvalue(),
- "=== target is 'new'\n")
+ "=== target is u'new'\n")
def test_diff_directory(self):
self.build_tree(['new-tree/new-dir/'])
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2009-03-27 04:10:25 +0000
+++ b/bzrlib/workingtree.py 2009-03-31 00:12:10 +0000
@@ -969,7 +969,8 @@
return file_id
def get_symlink_target(self, file_id):
- return os.readlink(self.id2abspath(file_id).encode(osutils._fs_enc))
+ return os.readlink(self.id2abspath(file_id).encode(osutils._fs_enc)
+ ).decode(osutils._fs_enc)
@needs_write_lock
def subsume(self, other_tree):
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2009-03-27 04:10:25 +0000
+++ b/bzrlib/workingtree_4.py 2009-03-31 00:12:10 +0000
@@ -1739,10 +1739,9 @@
if entry[1][parent_index][0] != 'l':
return None
else:
- # At present, none of the tree implementations supports non-ascii
- # symlink targets. So we will just assume that the dirstate path is
- # correct.
- return entry[1][parent_index][1]
+ target = entry[1][parent_index][1]
+ target = target.decode('utf8')
+ return target
def get_revision_id(self):
"""Return the revision id for this tree."""
More information about the bazaar-commits
mailing list