/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Robert Collins
  • Date: 2005-10-20 07:48:48 UTC
  • mfrom: (1475)
  • mto: This revision was merged to the branch mainline in revision 1477.
  • Revision ID: robertc@robertcollins.net-20051020074848-6dde0abbc59a1238
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
"""Implementation of Transport for the local filesystem.
17
 
"""
 
16
 
 
17
"""Transport for the local filesystem.
 
18
 
 
19
This is a fairly thin wrapper on regular file IO."""
18
20
 
19
21
import os
20
22
import errno
21
23
import shutil
22
24
from stat import ST_MODE, S_ISDIR, ST_SIZE
23
25
import tempfile
 
26
import urllib
24
27
 
25
28
from bzrlib.trace import mutter
26
29
from bzrlib.transport import Transport, register_transport, \
27
30
    TransportError, NoSuchFile, FileExists
28
 
 
 
31
from bzrlib.osutils import abspath
29
32
 
30
33
class LocalTransportError(TransportError):
31
34
    pass
41
44
        # realpath is incompatible with symlinks. When we traverse
42
45
        # up we might be able to normpath stuff. RBC 20051003
43
46
        super(LocalTransport, self).__init__(
44
 
            os.path.normpath(os.path.abspath(base)))
 
47
            os.path.normpath(abspath(base)))
45
48
 
46
49
    def should_cache(self):
47
50
        return False
57
60
            return LocalTransport(self.abspath(offset))
58
61
 
59
62
    def abspath(self, relpath):
60
 
        """Return the full url to the given relative path.
 
63
        """Return the full url to the given relative URL.
61
64
        This can be supplied with a string or a list
62
65
        """
63
 
        if isinstance(relpath, basestring):
64
 
            relpath = [relpath]
65
 
        return os.path.join(self.base, *relpath)
 
66
        assert isinstance(relpath, basestring)
 
67
        return os.path.join(self.base, urllib.unquote(relpath))
66
68
 
67
69
    def relpath(self, abspath):
68
70
        """Return the local path portion from a given absolute path.
241
243
    def __del__(self):
242
244
        shutil.rmtree(self.base, ignore_errors=True)
243
245
        mutter("%r destroyed" % self)
244
 
 
245
 
# If nothing else matches, try the LocalTransport
246
 
register_transport(None, LocalTransport)
247
 
register_transport('file://', LocalTransport)