/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/http/__init__.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
        else:
170
170
            # TODO: Don't call this with an array - no magic interfaces
171
171
            relpath_parts = relpath[:]
172
 
        if len(relpath_parts) > 1:
173
 
            # TODO: Check that the "within branch" part of the
174
 
            # error messages below is relevant in all contexts
175
 
            if relpath_parts[0] == '':
176
 
                raise ValueError("path %r within branch %r seems to be absolute"
177
 
                                 % (relpath, self._path))
178
 
            # read only transports never manipulate directories
179
 
            if self.is_readonly() and relpath_parts[-1] == '':
 
172
        if relpath.startswith('/'):
 
173
            basepath = []
 
174
        else:
 
175
            # Except for the root, no trailing slashes are allowed
 
176
            if len(relpath_parts) > 1 and relpath_parts[-1] == '':
180
177
                raise ValueError("path %r within branch %r seems to be a directory"
181
178
                                 % (relpath, self._path))
182
 
        basepath = self._path.split('/')
183
 
        if len(basepath) > 0 and basepath[-1] == '':
184
 
            basepath = basepath[:-1]
 
179
            basepath = self._path.split('/')
 
180
            if len(basepath) > 0 and basepath[-1] == '':
 
181
                basepath = basepath[:-1]
 
182
 
185
183
        for p in relpath_parts:
186
184
            if p == '..':
187
185
                if len(basepath) == 0:
254
252
            f.seek(start, (start < 0) and 2 or 0)
255
253
            start = f.tell()
256
254
            data = f.read(size)
257
 
            assert len(data) == size
 
255
            if len(data) != size:
 
256
                raise errors.ShortReadvError(relpath, start, size,
 
257
                                             actual=len(data))
258
258
            yield start, data
259
259
 
260
260
    @staticmethod
371
371
 
372
372
    def clone(self, offset=None):
373
373
        """Return a new HttpTransportBase with root at self.base + offset
374
 
        For now HttpTransportBase does not actually connect, so just return
375
 
        a new HttpTransportBase object.
 
374
 
 
375
        We leave the daughter classes take advantage of the hint
 
376
        that it's a cloning not a raw creation.
376
377
        """
377
378
        if offset is None:
378
 
            return self.__class__(self.base)
 
379
            return self.__class__(self.base, self)
379
380
        else:
380
 
            return self.__class__(self.abspath(offset))
 
381
            return self.__class__(self.abspath(offset), self)
381
382
 
382
383
    @staticmethod
383
384
    def range_header(ranges, tail_amount):
449
450
        if not self.parse_request(): # An error code has been sent, just exit
450
451
            return
451
452
        mname = 'do_' + self.command
452
 
        if not hasattr(self, mname):
 
453
        if getattr(self, mname, None) is None:
453
454
            self.send_error(501, "Unsupported method (%r)" % self.command)
454
455
            return
455
456
        method = getattr(self, mname)