~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-09 17:13:04 UTC
  • mto: (5029.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5030.
  • Revision ID: v.ladeuil+lp@free.fr-20100209171304-2ppoju422x02s7fm
Move MemoryServer to bzrlib.tests.test_server

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):
307
 
    """Server for the MemoryTransport for testing with."""
308
 
 
309
 
    def start_server(self):
310
 
        self._dirs = {'/':None}
311
 
        self._files = {}
312
 
        self._locks = {}
313
 
        self._scheme = "memory+%s:///" % id(self)
314
 
        def memory_factory(url):
315
 
            result = MemoryTransport(url)
316
 
            result._dirs = self._dirs
317
 
            result._files = self._files
318
 
            result._locks = self._locks
319
 
            return result
320
 
        self._memory_factory = memory_factory
321
 
        register_transport(self._scheme, self._memory_factory)
322
 
 
323
 
    def stop_server(self):
324
 
        # unregister this server
325
 
        unregister_transport(self._scheme, self._memory_factory)
326
 
 
327
 
    def get_url(self):
328
 
        """See bzrlib.transport.Server.get_url."""
329
 
        return self._scheme
330
 
 
331
 
 
332
303
def get_test_permutations():
333
304
    """Return the permutations to be used in testing."""
334
 
    return [(MemoryTransport, MemoryServer),
 
305
    from bzrlib.tests import test_server
 
306
    return [(MemoryTransport, test_server.MemoryServer),
335
307
            ]