~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

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