[Preview/RFC] win32 fake symlinks

Alexander Belchenko bialix at ukr.net
Sat Nov 3 18:11:00 GMT 2007


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

Alexander Belchenko пишет:
> John Arbash Meinel ?8H5B:
>> Alexander Belchenko wrote:
>> a) you should still use try/finally . It isn't huge when there is only 1
>> command, but it it good to be in the habit.

Done.

>> c) Is there an encoding for these paths? How do you set a link to a Unicode
>> path. I would probably recommend using UTF-8. Though on Win32 using MBCS might
>> be reasonable (since that is the path encoding anyway). But that puts '\0'
>> characters in your strings, and you are using that as the EOF.
>> I'm guessing your current implementation is ending up using OEM encoding. But
>> that only works for the subset that is in your code page.
> 
> I don't know how Cygwin deals with unicode. In my understanding
> it just don't support unicode at all. I know we prefer utf-8 everywhere, so I'm OK
> to use it. But if someone familiar with Cygwins internals, I'd like to know
> how Cygwin supports unicode in symlinks.

I did some experiments, and in fact Cygwin does not understand utf-8 in symlinks,
but instead use bzrlib.user_encoding. So, I changed my code in appropriate way.

>> f) I would probably prefer it if this functionality was optional. (Provided by
>> a plugin.) It doesn't make a lot of sense to penalize all the normal Win32
>> users by checking every file if it is a symlink. Especially considering that
>> most Win32 projects won't/can't use them.

I have 2 reasons to insist on including this in the bzrlib core:

1) There is at least 2 functions in bzrlib that uses os.lstat at the import time:

in osutils.py: def file_kind(f, _lstat=os.lstat, _mapper=file_kind_from_stat_mode):
in workingtree.py: def path_content_summary(self, path, _lstat=os.lstat,
        _mapper=osutils.file_kind_from_stat_mode):

So if do it in plugin I need at least monleypatching file_kind, because osutils.py
is imported before any plugin loaded. workingtree.py is mostly imported via lazy_import
mechanism, so it should be safe to not monkeypatching it. But who know what the future
will bring?

2) Mercurial 0.9.5 has built-in support for fake symlinks on non-Linux platfrom.
(Though their implementation is much dumbier.)
http://www.selenic.com/pipermail/mercurial/2007-October/015150.html

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

iD8DBQFHLLm0zYr338mxwCURAuLLAJ9ah7Ou36+Bin+zNJ5yuh6rfHIgwQCfW+uf
YuASOKihfODDxK2pWT+uVPw=
=11IJ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list