~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-16 01:25:46 UTC
  • mfrom: (2071 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: john@arbash-meinel.com-20061016012546-d01a0740671b4d73
[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
import os
 
23
from stat import ST_MODE, S_ISDIR, ST_SIZE, S_IMODE
 
24
import sys
 
25
 
 
26
from bzrlib.lazy_import import lazy_import
 
27
lazy_import(globals(), """
22
28
import errno
23
 
import os
24
29
import shutil
25
 
import sys
26
 
from stat import ST_MODE, S_ISDIR, ST_SIZE, S_IMODE
27
 
import tempfile
28
30
 
29
31
from bzrlib import (
30
32
    atomicfile,
31
33
    osutils,
32
34
    urlutils,
 
35
    symbol_versioning,
33
36
    )
34
 
from bzrlib.osutils import (abspath, realpath, normpath, pathjoin, rename,
35
 
                            check_legal_path, rmtree)
36
 
from bzrlib.symbol_versioning import warn
37
37
from bzrlib.trace import mutter
 
38
""")
 
39
 
38
40
from bzrlib.transport import Transport, Server
39
41
 
40
42
 
48
50
    def __init__(self, base):
49
51
        """Set the base path where files will be stored."""
50
52
        if not base.startswith('file://'):
51
 
            warn("Instantiating LocalTransport with a filesystem path"
 
53
            symbol_versioning.warn(
 
54
                "Instantiating LocalTransport with a filesystem path"
52
55
                " is deprecated as of bzr 0.8."
53
56
                " Please use bzrlib.transport.get_transport()"
54
57
                " or pass in a file:// url.",
91
94
        assert isinstance(relpath, basestring), (type(relpath), relpath)
92
95
        # jam 20060426 Using normpath on the real path, because that ensures
93
96
        #       proper handling of stuff like
94
 
        path = normpath(pathjoin(self._local_base, urlutils.unescape(relpath)))
 
97
        path = osutils.normpath(osutils.pathjoin(
 
98
                    self._local_base, urlutils.unescape(relpath)))
95
99
        return urlutils.local_path_to_url(path)
96
100
 
97
101
    def local_abspath(self, relpath):
145
149
        path = relpath
146
150
        try:
147
151
            path = self._abspath(relpath)
148
 
            check_legal_path(path)
 
152
            osutils.check_legal_path(path)
149
153
            fp = atomicfile.AtomicFile(path, 'wb', new_mode=mode)
150
154
        except (IOError, OSError),e:
151
155
            self._translate_error(e, path)
165
169
        path = relpath
166
170
        try:
167
171
            path = self._abspath(relpath)
168
 
            check_legal_path(path)
 
172
            osutils.check_legal_path(path)
169
173
            fp = atomicfile.AtomicFile(path, 'wb', new_mode=mode)
170
174
        except (IOError, OSError),e:
171
175
            self._translate_error(e, path)
366
370
 
367
371
        try:
368
372
            # this version will delete the destination if necessary
369
 
            rename(path_from, path_to)
 
373
            osutils.rename(path_from, path_to)
370
374
        except (IOError, OSError),e:
371
375
            # TODO: What about path_to?
372
376
            self._translate_error(e, path_from)