~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-22 07:28:09 UTC
  • mfrom: (1551.2.56 win32fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20060422072809-b06e742274a4e9f4
Misc fixes for win32

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib.trace import mutter
29
29
from bzrlib.transport import Transport, Server
30
 
from bzrlib.osutils import abspath, realpath, normpath, pathjoin, rename
 
30
from bzrlib.osutils import (abspath, realpath, normpath, pathjoin, rename, 
 
31
                            check_legal_path)
31
32
 
32
33
 
33
34
class LocalTransport(Transport):
68
69
    def relpath(self, abspath):
69
70
        """Return the local path portion from a given absolute path.
70
71
        """
71
 
        from bzrlib.osutils import relpath
 
72
        from bzrlib.osutils import relpath, strip_trailing_slash
72
73
        if abspath is None:
73
74
            abspath = u'.'
74
 
        if len(abspath) > 1 and abspath.endswith('/'):
75
 
            abspath = abspath[:-1]
76
 
        if self.base == '/':
77
 
            root = '/'
78
 
        else:
79
 
            root = self.base[:-1]
80
 
        return relpath(root, abspath)
 
75
 
 
76
        return relpath(strip_trailing_slash(self.base), 
 
77
                       strip_trailing_slash(abspath))
81
78
 
82
79
    def has(self, relpath):
83
80
        return os.access(self.abspath(relpath), os.F_OK)
104
101
        path = relpath
105
102
        try:
106
103
            path = self.abspath(relpath)
 
104
            check_legal_path(path)
107
105
            fp = AtomicFile(path, 'wb', new_mode=mode)
108
106
        except (IOError, OSError),e:
109
107
            self._translate_error(e, path)