/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from __future__ import absolute_import
24
24
 
25
 
import contextlib
26
25
import os
27
26
import errno
28
27
from stat import S_IFREG, S_IFDIR
 
28
from cStringIO import StringIO
29
29
 
30
 
from .. import (
 
30
from bzrlib import (
31
31
    transport,
32
32
    urlutils,
33
33
    )
34
 
from ..errors import (
 
34
from bzrlib.errors import (
35
35
    FileExists,
36
36
    LockError,
37
37
    InProcessTransport,
38
38
    NoSuchFile,
39
39
    )
40
 
from ..sixish import (
41
 
    BytesIO,
42
 
    )
43
 
from ..transport import (
 
40
from bzrlib.transport import (
44
41
    AppendBasedFileStream,
45
42
    _file_streams,
46
43
    LateReadError,
54
51
        self.st_size = size
55
52
        if not is_dir:
56
53
            if perms is None:
57
 
                perms = 0o644
 
54
                perms = 0644
58
55
            self.st_mode = S_IFREG | perms
59
56
        else:
60
57
            if perms is None:
61
 
                perms = 0o755
 
58
                perms = 0755
62
59
            self.st_mode = S_IFDIR | perms
63
60
 
64
61
 
132
129
        del self._files[_abspath]
133
130
 
134
131
    def external_url(self):
135
 
        """See breezy.transport.Transport.external_url."""
 
132
        """See bzrlib.transport.Transport.external_url."""
136
133
        # MemoryTransport's are only accessible in-process
137
134
        # so we raise here
138
135
        raise InProcessTransport(self)
145
142
                return LateReadError(relpath)
146
143
            else:
147
144
                raise NoSuchFile(relpath)
148
 
        return BytesIO(self._files[_abspath][0])
 
145
        return StringIO(self._files[_abspath][0])
149
146
 
150
147
    def put_file(self, relpath, f, mode=None):
151
148
        """See Transport.put_file()."""
165
162
 
166
163
    def open_write_stream(self, relpath, mode=None):
167
164
        """See Transport.open_write_stream."""
168
 
        self.put_bytes(relpath, b"", mode)
 
165
        self.put_bytes(relpath, "", mode)
169
166
        result = AppendBasedFileStream(self, relpath)
170
167
        _file_streams[self.abspath(relpath)] = result
171
168
        return result
194
191
                if path.startswith(_abspath):
195
192
                    trailing = path[len(_abspath):]
196
193
                    if trailing and '/' not in trailing:
197
 
                        result.append(urlutils.escape(trailing))
198
 
        return result
 
194
                        result.append(trailing)
 
195
        return map(urlutils.escape, result)
199
196
 
200
197
    def rename(self, rel_from, rel_to):
201
198
        """Rename a file or directory; fail if the destination exists"""
298
295
        self._locks = {}
299
296
        self._scheme = "memory+%s:///" % id(self)
300
297
        def memory_factory(url):
301
 
            from . import memory
 
298
            from bzrlib.transport import memory
302
299
            result = memory.MemoryTransport(url)
303
300
            result._dirs = self._dirs
304
301
            result._files = self._files
312
309
        transport.unregister_transport(self._scheme, self._memory_factory)
313
310
 
314
311
    def get_url(self):
315
 
        """See breezy.transport.Server.get_url."""
 
312
        """See bzrlib.transport.Server.get_url."""
316
313
        return self._scheme
317
314
 
318
315
    def get_bogus_url(self):