~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
28
28
import warnings
29
29
 
30
30
from bzrlib import (
 
31
    transport,
31
32
    urlutils,
32
33
    )
33
34
from bzrlib.errors import (
42
43
    AppendBasedFileStream,
43
44
    _file_streams,
44
45
    LateReadError,
45
 
    register_transport,
46
 
    Server,
47
 
    Transport,
48
 
    unregister_transport,
49
46
    )
50
47
 
51
48
 
64
61
            self.st_mode = S_IFDIR | perms
65
62
 
66
63
 
67
 
class MemoryTransport(Transport):
 
64
class MemoryTransport(transport.Transport):
68
65
    """This is an in memory file system for transient data storage."""
69
66
 
70
67
    def __init__(self, url=""):
303
300
        self.transport = None
304
301
 
305
302
 
306
 
class MemoryServer(Server):
 
303
class MemoryServer(transport.Server):
307
304
    """Server for the MemoryTransport for testing with."""
308
305
 
309
306
    def start_server(self):
312
309
        self._locks = {}
313
310
        self._scheme = "memory+%s:///" % id(self)
314
311
        def memory_factory(url):
315
 
            result = MemoryTransport(url)
 
312
            from bzrlib.transport import memory
 
313
            result = memory.MemoryTransport(url)
316
314
            result._dirs = self._dirs
317
315
            result._files = self._files
318
316
            result._locks = self._locks
319
317
            return result
320
318
        self._memory_factory = memory_factory
321
 
        register_transport(self._scheme, self._memory_factory)
 
319
        transport.register_transport(self._scheme, self._memory_factory)
322
320
 
323
321
    def stop_server(self):
324
322
        # unregister this server
325
 
        unregister_transport(self._scheme, self._memory_factory)
 
323
        transport.unregister_transport(self._scheme, self._memory_factory)
326
324
 
327
325
    def get_url(self):
328
326
        """See bzrlib.transport.Server.get_url."""
329
327
        return self._scheme
330
328
 
 
329
    def get_bogus_url(self):
 
330
        raise NotImplementedError
 
331
 
331
332
 
332
333
def get_test_permutations():
333
334
    """Return the permutations to be used in testing."""