Rev 4219: (robertc) Make Tree.get_symlink_target consistently return decoded in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Mar 31 06:51:54 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4219
revision-id: pqm at pqm.ubuntu.com-20090331055149-vjdpx8awxkxema5i
parent: pqm at pqm.ubuntu.com-20090331011133-3mpb7ocwv4eu6go4
parent: robertc at robertcollins.net-20090331001210-fufeq2heozx9jne0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-03-31 06:51:49 +0100
message:
  (robertc) Make Tree.get_symlink_target consistently return decoded
  	strings. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 4216.3.1
    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:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== 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