/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 breezy/transport/memory.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    )
49
49
 
50
50
 
51
 
 
52
51
class MemoryStat(object):
53
52
 
54
53
    def __init__(self, size, kind, perms):
81
80
        self._scheme = url[:split]
82
81
        self._cwd = url[split:]
83
82
        # dictionaries from absolute path to file mode
84
 
        self._dirs = {'/':None}
 
83
        self._dirs = {'/': None}
85
84
        self._symlinks = {}
86
85
        self._files = {}
87
86
        self._locks = {}
129
128
    def has(self, relpath):
130
129
        """See Transport.has()."""
131
130
        _abspath = self._abspath(relpath)
132
 
        return ((_abspath in self._files) or
133
 
                (_abspath in self._dirs) or
134
 
                (_abspath in self._symlinks))
 
131
        return ((_abspath in self._files)
 
132
                or (_abspath in self._dirs)
 
133
                or (_abspath in self._symlinks))
135
134
 
136
135
    def delete(self, relpath):
137
136
        """See Transport.delete()."""
170
169
        self._check_parent(_abspath)
171
170
        if _abspath in self._dirs:
172
171
            raise FileExists(relpath)
173
 
        self._dirs[_abspath]=mode
 
172
        self._dirs[_abspath] = mode
174
173
 
175
174
    def open_write_stream(self, relpath, mode=None):
176
175
        """See Transport.open_write_stream."""
254
253
                                      relpath)
255
254
        for path in self._dirs:
256
255
            if path.startswith(_abspath + '/') and path != _abspath:
257
 
                self._translate_error(IOError(errno.ENOTEMPTY, relpath), relpath)
 
256
                self._translate_error(
 
257
                    IOError(errno.ENOTEMPTY, relpath), relpath)
258
258
        if not _abspath in self._dirs:
259
259
            raise NoSuchFile(relpath)
260
260
        del self._dirs[_abspath]
292
292
            if i == '..':
293
293
                if not r:
294
294
                    raise ValueError("illegal relpath %r under %r"
295
 
                        % (relpath, self._cwd))
 
295
                                     % (relpath, self._cwd))
296
296
                r = r[:-1]
297
297
            elif i == '.' or i == '':
298
298
                pass
334
334
    """Server for the MemoryTransport for testing with."""
335
335
 
336
336
    def start_server(self):
337
 
        self._dirs = {'/':None}
 
337
        self._dirs = {'/': None}
338
338
        self._files = {}
339
339
        self._locks = {}
340
340
        self._scheme = "memory+%s:///" % id(self)
 
341
 
341
342
        def memory_factory(url):
342
343
            from . import memory
343
344
            result = memory.MemoryTransport(url)