~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-22 18:09:04 UTC
  • mfrom: (2485.8.63 bzr.connection.sharing)
  • Revision ID: pqm@pqm.ubuntu.com-20070722180904-wy7y7oyi32wbghgf
Transport connection sharing

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from cStringIO import StringIO
28
28
import warnings
29
29
 
30
 
from bzrlib.errors import TransportError, NoSuchFile, FileExists, LockError
 
30
from bzrlib.errors import (
 
31
    FileExists,
 
32
    LockError,
 
33
    InProcessTransport,
 
34
    NoSuchFile,
 
35
    TransportError,
 
36
    )
31
37
from bzrlib.trace import mutter
32
 
from bzrlib.transport import (Transport, register_transport, Server)
 
38
from bzrlib.transport import (
 
39
    LateReadError,
 
40
    register_transport,
 
41
    Server,
 
42
    Transport,
 
43
    )
33
44
import bzrlib.urlutils as urlutils
34
45
 
35
46
 
117
128
            raise NoSuchFile(relpath)
118
129
        del self._files[_abspath]
119
130
 
 
131
    def external_url(self):
 
132
        """See bzrlib.transport.Transport.external_url."""
 
133
        # MemoryTransport's are only accessible in-process
 
134
        # so we raise here
 
135
        raise InProcessTransport(self)
 
136
 
120
137
    def get(self, relpath):
121
138
        """See Transport.get()."""
122
139
        _abspath = self._abspath(relpath)
123
140
        if not _abspath in self._files:
124
 
            raise NoSuchFile(relpath)
 
141
            if _abspath in self._dirs:
 
142
                return LateReadError(relpath)
 
143
            else:
 
144
                raise NoSuchFile(relpath)
125
145
        return StringIO(self._files[_abspath][0])
126
146
 
127
147
    def put_file(self, relpath, f, mode=None):