[MERGE][1.13][#339055][#272444] Non ascii symlink target and related warnings

John Arbash Meinel john at arbash-meinel.com
Tue Mar 10 23:40:21 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> The attached should fix quite a few problems around non ASCII symlink
> targets.
> 
> But given the horrors I encountered during its conception, I'm not sure
> I caught all the corner and edge cases.
> 
> At least it's better than what we have and clearly fix #339055.
> 
>    Vincent
> 
> 

BB:tweak

=== modified file 'bzrlib/dirstate.py'
- --- bzrlib/dirstate.py	2009-02-23 15:29:35 +0000
+++ bzrlib/dirstate.py	2009-03-10 08:55:11 +0000
@@ -1588,7 +1588,13 @@
         #       already in memory. However, this really needs to be
done at a
         #       higher level, because there either won't be anything on
disk,
         #       or the thing on disk will be a file.
- -        return os.readlink(abspath.encode(osutils._fs_enc))
+        if isinstance(abspath, unicode):
+            # abspath is defined as the path to pass to lstat. readlink is
+            # buggy in python < 2.6 (it doesn't encode unicode path into FS
+            # encoding), so we need to encode ourselves knowing that
unicode
+            # paths are produced by UnicodeDirReader on purpose.
+            abspath = abspath.encode(osutils._fs_enc)
+        return os.readlink(abspath)


^- Dirstate wants link targets in UTF-8, but some platforms have _fs_enc
!= UTF-8 at this point. So we should check, and
.decode(fs_enc).encode('UTF-8') in that case.

- -            # We don't support non-ascii targets for symlinks yet.
- -            fingerprint = str(inv_entry.symlink_target or '')
+            fingerprint = inv_entry.symlink_target.encode('utf8') or ''

^- The earlier workaround is because 'symlink_target' may be None which
doesn't have an 'encode'. However, we can just check that symlink_target
is None or not.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm2+mUACgkQJdeBCYSNAAOwOgCfVWWPiTnP/jmfcqeRTffO/w1V
NhMAn1ImEtiG4rA/mtpQxsfxWr/HPbkm
=+3xt
-----END PGP SIGNATURE-----



More information about the bazaar mailing list