[RFC] symlinks support on win32: what features really needed or bzr?

Martin Pool mbp at sourcefrog.net
Wed Oct 31 20:53:36 GMT 2007


On 10/30/07, John Arbash Meinel <john at arbash-meinel.com> wrote:

> I'm guessing we don't need to support os.path.realpath() for windows. Unless
> you want to be able to refer to branches using a symlink. That, to my
> knowledge, is all we use realpath for. (Which is only really relevant when
> /path/to/branch is has a symlink in it.)
>
> For supporting links inside the working tree, we probably only check whether it
> *is* a symlink (osutils.file_kind_from_stat_mode), and then os.readlink to see
> where it points (which we commit.) and then "os.symlink" to create or change a
> symlink on disk.

I think John's right that we should normally only be reading links in
the working tree, not dereferencing them.  Doing otherwise is probably
a bug.

It would be kind of nice if we could arrange to use the win32 approach
for symlinks, maybe for people who have special situations (on a samba
share?), but at least so we can test them.  Maybe you could make all
the tests for symlinks be run in two scenarios, real and fake
symlinks.  I wouldn't insist on this to merge, it's just an idea.
> Most code that follows symlinks has a loop of (pseudocode):
>
> while is_link(path):
>  path = readlink(path)

Just to be clear, this loop is done in the kernel, not the
application.  If you just open the symlink, you get the ultimate
target, or an error if any link in the chain is broken, or an error if
there is a loop.

-- 
Martin



More information about the bazaar mailing list