~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Robert Collins
  • Date: 2005-10-16 09:30:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016093048-9d12448dab8f8b97
rebuild ScratchBranch on top of ScratchTransport

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
"""Implementation of Transport for the local filesystem.
17
17
"""
18
18
 
 
19
import os
 
20
import errno
 
21
import shutil
 
22
import tempfile
 
23
 
 
24
from bzrlib.trace import mutter
19
25
from bzrlib.transport import Transport, register_transport, \
20
26
    TransportError, NoSuchFile, FileExists
21
 
import os, errno
 
27
 
22
28
 
23
29
class LocalTransportError(TransportError):
24
30
    pass
25
31
 
 
32
 
26
33
class LocalTransport(Transport):
27
34
    """This is the transport agent for local filesystem access."""
28
35
 
235
242
    Obviously you should not put anything precious in it.
236
243
    """
237
244
 
238
 
    def __init__(self):
239
 
        base = tempfile.mkdtemp()
 
245
    def __init__(self, base=None):
 
246
        if base is None:
 
247
            base = tempfile.mkdtemp()
240
248
        super(ScratchTransport, self).__init__(base)
241
249
 
242
250
    def __del__(self):
243
 
        self.delete_multi(self._transport.list_dir('.'))
244
 
        os.rmdir(self._transport.base)
 
251
        shutil.rmtree(self.base, ignore_errors=True)
245
252
        mutter("%r destroyed" % self)
246
 
        super(ScratchTransport, self).__del__()
247
253
 
248
254
# If nothing else matches, try the LocalTransport
249
255
register_transport(None, LocalTransport)