~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Mark Hammond
  • Date: 2009-01-12 01:55:34 UTC
  • mto: (3995.8.2 prepare-1.12)
  • mto: This revision was merged to the branch mainline in revision 4007.
  • Revision ID: mhammond@skippinet.com.au-20090112015534-yfxg50p7mpds9j4v
Include all .html files from the tortoise doc directory.

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, 2006 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Implementation of Transport that uses memory for its storage.
18
18
 
27
27
from cStringIO import StringIO
28
28
import warnings
29
29
 
30
 
from bzrlib import (
31
 
    urlutils,
32
 
    )
33
30
from bzrlib.errors import (
34
31
    FileExists,
35
32
    LockError,
45
42
    register_transport,
46
43
    Server,
47
44
    Transport,
48
 
    unregister_transport,
49
45
    )
 
46
import bzrlib.urlutils as urlutils
50
47
 
51
48
 
52
49
 
88
85
        if len(path) == 0 or path[-1] != '/':
89
86
            path += '/'
90
87
        url = self._scheme + path
91
 
        result = self.__class__(url)
 
88
        result = MemoryTransport(url)
92
89
        result._dirs = self._dirs
93
90
        result._files = self._files
94
91
        result._locks = self._locks
186
183
        for file in self._files:
187
184
            if file.startswith(self._cwd):
188
185
                yield urlutils.escape(file[len(self._cwd):])
189
 
 
 
186
    
190
187
    def list_dir(self, relpath):
191
188
        """See Transport.list_dir()."""
192
189
        _abspath = self._abspath(relpath)
225
222
                    del container[path]
226
223
        do_renames(self._files)
227
224
        do_renames(self._dirs)
228
 
 
 
225
    
229
226
    def rmdir(self, relpath):
230
227
        """See Transport.rmdir."""
231
228
        _abspath = self._abspath(relpath)
246
243
        """See Transport.stat()."""
247
244
        _abspath = self._abspath(relpath)
248
245
        if _abspath in self._files:
249
 
            return MemoryStat(len(self._files[_abspath][0]), False,
 
246
            return MemoryStat(len(self._files[_abspath][0]), False, 
250
247
                              self._files[_abspath][1])
251
248
        elif _abspath in self._dirs:
252
249
            return MemoryStat(0, True, self._dirs[_abspath])
306
303
class MemoryServer(Server):
307
304
    """Server for the MemoryTransport for testing with."""
308
305
 
309
 
    def start_server(self):
 
306
    def setUp(self):
 
307
        """See bzrlib.transport.Server.setUp."""
310
308
        self._dirs = {'/':None}
311
309
        self._files = {}
312
310
        self._locks = {}
317
315
            result._files = self._files
318
316
            result._locks = self._locks
319
317
            return result
320
 
        self._memory_factory = memory_factory
321
 
        register_transport(self._scheme, self._memory_factory)
 
318
        register_transport(self._scheme, memory_factory)
322
319
 
323
 
    def stop_server(self):
 
320
    def tearDown(self):
 
321
        """See bzrlib.transport.Server.tearDown."""
324
322
        # unregister this server
325
 
        unregister_transport(self._scheme, self._memory_factory)
326
323
 
327
324
    def get_url(self):
328
325
        """See bzrlib.transport.Server.get_url."""