~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Martin
  • Date: 2010-05-03 20:57:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5204.
  • Revision ID: gzlist@googlemail.com-20100503205739-n326zdvevv0rmruh
Retain original stack and error message when translating to ValueError in bencode

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
so this is primarily useful for testing.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
24
 
 
25
23
import os
26
24
import errno
 
25
import re
27
26
from stat import S_IFREG, S_IFDIR
28
27
from cStringIO import StringIO
 
28
import warnings
29
29
 
30
30
from bzrlib import (
31
31
    transport,
36
36
    LockError,
37
37
    InProcessTransport,
38
38
    NoSuchFile,
 
39
    TransportError,
39
40
    )
 
41
from bzrlib.trace import mutter
40
42
from bzrlib.transport import (
41
43
    AppendBasedFileStream,
42
44
    _file_streams,
79
81
 
80
82
    def clone(self, offset=None):
81
83
        """See Transport.clone()."""
82
 
        path = urlutils.URL._combine_paths(self._cwd, offset)
 
84
        path = self._combine_paths(self._cwd, offset)
83
85
        if len(path) == 0 or path[-1] != '/':
84
86
            path += '/'
85
87
        url = self._scheme + path
287
289
            raise LockError('File %r already locked' % (self.path,))
288
290
        self.transport._locks[self.path] = self
289
291
 
 
292
    def __del__(self):
 
293
        # Should this warn, or actually try to cleanup?
 
294
        if self.transport:
 
295
            warnings.warn("MemoryLock %r not explicitly unlocked" % (self.path,))
 
296
            self.unlock()
 
297
 
290
298
    def unlock(self):
291
299
        del self.transport._locks[self.path]
292
300
        self.transport = None