~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: 2010-01-15 04:49:48 UTC
  • mfrom: (3984.5.22 switch-r-183559)
  • Revision ID: pqm@pqm.ubuntu.com-20100115044948-yxz5m3vchxapbq22
(andrew) Add --revision option to 'bzr switch'. (#184559)

Show diffs side-by-side

added added

removed removed

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