1
####################################
2
Developer guide to bzrlib transports
3
####################################
5
This guide describes the `Transport` classes that Bazaar uses for most
6
local and remote file access. (Working tree files are the major
13
A symlink creates an alias where files or directories can be accessed by a
14
different name. Symlinks are annoying.
16
It's important to have tests for symlinks but there tests can't run on
17
Windows, so you need eg ::
19
_test_needs_features = [tests.SymlinkFeature]
23
self.requireFeature(tests.SymlinkFeature)
25
Bazaar versions symlinks as objects in their own right, whose content is
26
the (Unicode) path they point to. bzr doesn't care whether a versioned
27
symlink is absolute or relative; or whether it points inside or outside
28
the working tree; or whether its referent exists or not.
30
So when we say ``bzr add symlink``, this should always add the symlink to
31
its containing working tree, and never dereference the symlink.
33
However, ``bzr add symlink/file`` shouldn't add ``file`` as a child of
34
``symlink``. (Symlinks don't have files underneath them: they may point to
35
a directory which contains children, but if the symlink was pointed
36
somewhere else those children would be unaffected.) This could either add
37
the file in its containing working tree, or fail outright.
39
One interesting case for this is ::
41
bzr add ~/dev/bug123/a.c
43
where ``~/dev`` is actually a symlink to ``/srv/dev/joe/``. In this case
44
clearly the user does want us to follow the symlink to open the tree.
46
As of bzr2.2, when we open a `WorkingTree`, we typically immediately
47
compute its real path and store that as ``.basedir``, but `BzrDir` stores
48
its apparent path. (This may not be the best thing.)
51
Relative paths beyond symlinks
52
------------------------------
54
Another interesting case is when a control directory contains a relative
55
path, perhaps from a branch to its master or from a working tree to its
56
branch. If it contains ``../`` parts as it typically will, these may have
57
different effects depending on whether they're looked up relative to the
58
real path or the apparent path given by the user. It may be that some
59
users expect different behaviours at different times.
61
Resolving the path relative to the real directory makes it somewhat more
62
consistent with what you would see by in a shell entering that directory
63
and then opening the given name. It may also make things more consistent
64
when there are multiple links to the same bzrdir. However it may cause
65
problems when using a transport that hides symlinks.
67
We could possibly handle this by doing less path arithmetic and asking the
68
OS or server to open the path including ``..`` and other relative
69
elements, but that might cause other problems. HTTP servers may do their
70
own path arithmetic before passing it to the OS.
73
Transports that hide symlinks
74
-----------------------------
76
On local, sftp and bzr+ssh transports, we can directly see symlinks as
77
symlinks. Over http (and ftp?) they're expanded by the server and we
78
cannot detect them. This can cause problems when bzr follows relative
79
paths because typically we will join the paths, and we may do this
80
inconsistently with how the server, which can see the symlinks, would do.
83
Symlinks and ChrootTransports
84
-----------------------------
86
bzr has an internal concept of a `ChrootTransport` that locks access into
87
a particular directory. Symlinks should not break out of a chroot jail
88
which implies they should be expanded and checked within bzrlib.
89
(At least as long as the transport lets us see the symlink; otherwise it