/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: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

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."""