[rfc] Proposal: fake symlinks support on windows
Alexander Belchenko
bialix at ukr.net
Thu May 18 14:06:33 BST 2006
Aaron Bentley пишет:
> Alexander Belchenko wrote:
>> I propose reuse cygwin format and gain full compatibility with cygwin.
>>
>> I propose to make special methods in bzrlib/osutils.py module:
>
> I don't think they should go there, because if we switch on platform,
> *nix won't handle these symlinks properly (i.e. if the tree is created
> by Windows, then accessed by *nix.)
>
> I think the symlink-handling approach should be per-working tree, and
> that *nix should use this style when working with a tree that was
> created by Windows.
I dig deeper. I played with symlinks on linux with vfat fylesystem. I
played with copying links between directories on cygwin.
Short summary: make a full cross-platform support and access to symlinks
in working tree from non-native filesystem is painful terrible work.
Windows and Cygwin share the same filesystem therefore they have good
compatibility. But anyway it's better don't mix them.
So I restrict my proposal for fake symlinks support to deal with
symlinks only inside bounds of native filesystem, without mixing access
to working tree from outside.
I wrote plugin that run-time-patches some modules:
* os module (adds symlink(), readlink() methods that absent on native
windows),
* os.path module (os.path.islink() function),
* bzrlib.osutils module (function file_kind()).
In addition I slightly change selftest and run tests with and without
patch. Fortunately all symlinks-specific tests passed, and I don't find
any regression in overall test suite.
If you insist to make all work with symlinks via WorkingTree methods
then there is need to grep and change all existing code and change
explicit os.symlink/os.readlink. That will be *very* big patch.
So at this moment I'd like to hear comments from developers that
interested in this symlink simulation. What my simple os-patching plugin
is missed? What additional tests should be added, improved?
In attachment you'll find patch for selftest subsystem of bzr. This
changes is not depend on windows nor cygwin. I've add test_symlinks.py
module with tests somewhat specific for my plugin. This tests looks
trivial for unix where I want to keep it separately and independetly in
main bzrlib code with reason to split namespaces.
I think this patch is worth to include in main bzr.dev.
My plugin you can reach here:
bzr branch http://bzr.onembedding.com/bzr.win/plugins/win32symlinks/
Results of symlink-specific tests
=================================
Command: python bzr selftest symlink -v
Run without plugin on win32 native
**********************************
bzr: D:/user/python/bzr/bzr.dev.symlinks/bzr
bzrlib: D:\user\python\bzr\bzr.dev.symlinks\bzrlib
test_inv.TestInventoryEntry.test_symlink_detect_changes OK
9ms
test_merge_core.MergeTest.test_symlink_conflicts SKIP
0ms
Symlinks are not supported on this platform
test_merge_core.MergeTest.test_symlink_merge SKIP
10ms
Symlinks are not supported on this platform
test_symlinks.TestSymlinks.test_has_symlinks_support SKIP
540ms
Symlinks are not supported on this platform
test_symlinks.TestSymlinks.test_symlink_readlink SKIP
0ms
Symlinks are not supported on this platform
test_testament.TestamentTests.test_testament_symlinks SKIP
1532ms
Symlinks are not supported on this platform
test_transform.TestTreeTransform.test_symlinks SKIP
610ms
Symlinks are not supported on this platform
----------------------------------------------------------------------
Ran 7 tests in 2.714s
OK
Run with plugin on win32 native
*******************************
bzr: D:/user/python/bzr/bzr.dev.symlinks/bzr
bzrlib: D:\user\python\bzr\bzr.dev.symlinks\bzrlib
test_inv.TestInventoryEntry.test_symlink_detect_changes OK
9ms
test_merge_core.MergeTest.test_symlink_conflicts OK
4185ms
test_merge_core.MergeTest.test_symlink_merge OK
4746ms
test_symlinks.TestSymlinks.test_has_symlinks_support OK
631ms
test_symlinks.TestSymlinks.test_symlink_readlink OK
9ms
test_testament.TestamentTests.test_testament_symlinks OK
2062ms
test_transform.TestTreeTransform.test_symlinks OK
842ms
----------------------------------------------------------------------
Ran 7 tests in 12.488s
OK
Run on cygwin
*************
bzr: /cygdrive/d/user/python/bzr/bzr.dev.symlinks/bzr
bzrlib: /cygdrive/d/user/python/bzr/bzr.dev.symlinks/bzrlib
test_inv.TestInventoryEntry.test_symlink_detect_changes OK
20ms
test_merge_core.MergeTest.test_symlink_conflicts OK
4275ms
test_merge_core.MergeTest.test_symlink_merge OK
4497ms
test_symlinks.TestSymlinks.test_has_symlinks_support OK
559ms
test_symlinks.TestSymlinks.test_symlink_readlink OK
9ms
test_testament.TestamentTests.test_testament_symlinks OK
1822ms
test_transform.TestTreeTransform.test_symlinks OK
791ms
----------------------------------------------------------------------
Ran 7 tests in 11.987s
OK
--
Alexander
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: symlinks_selftest.diff
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20060518/89bcc375/attachment.diff
More information about the bazaar
mailing list