~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-01 19:18:09 UTC
  • mfrom: (6459 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6460.
  • Revision ID: jelmer@samba.org-20120201191809-xn340a5i5v4fqsfu
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
This is a fairly thin wrapper on regular file IO.
20
20
"""
21
21
 
 
22
from __future__ import absolute_import
 
23
 
22
24
import os
23
25
from stat import ST_MODE, S_ISDIR, S_IMODE
24
26
import sys
72
74
 
73
75
        super(LocalTransport, self).__init__(base)
74
76
        self._local_base = urlutils.local_path_from_url(base)
 
77
        if self._local_base[-1] != '/':
 
78
            self._local_base = self._local_base + '/'
75
79
 
76
80
    def clone(self, offset=None):
77
81
        """Return a new LocalTransport with root at self.base + offset
144
148
        if abspath is None:
145
149
            abspath = u'.'
146
150
 
147
 
        return urlutils.file_relpath(
148
 
            urlutils.strip_trailing_slash(self.base),
149
 
            urlutils.strip_trailing_slash(abspath))
 
151
        return urlutils.file_relpath(self.base, abspath)
150
152
 
151
153
    def has(self, relpath):
152
154
        return os.access(self._abspath(relpath), os.F_OK)
329
331
    def open_write_stream(self, relpath, mode=None):
330
332
        """See Transport.open_write_stream."""
331
333
        abspath = self._abspath(relpath)
332
 
        handle = osutils.open_file(abspath, 'wb')
 
334
        try:
 
335
            handle = osutils.open_file(abspath, 'wb')
 
336
        except (IOError, OSError),e:
 
337
            self._translate_error(e, abspath)
333
338
        handle.truncate()
334
339
        if mode is not None:
335
340
            self._check_mode_and_size(abspath, handle.fileno(), mode)
536
541
            """See Transport.symlink."""
537
542
            abs_link_dirpath = urlutils.dirname(self.abspath(link_name))
538
543
            source_rel = urlutils.file_relpath(
539
 
                urlutils.strip_trailing_slash(abs_link_dirpath),
540
 
                urlutils.strip_trailing_slash(self.abspath(source))
541
 
            )
 
544
                abs_link_dirpath, self.abspath(source))
542
545
 
543
546
            try:
544
547
                os.symlink(source_rel, self._abspath(link_name))