~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
    def _abspath(self, relpath):
197
197
        assert isinstance(relpath, basestring)
198
198
        relpath = urlutils.unescape(relpath)
199
 
        relpath_parts = relpath.split('/')
200
 
        if len(relpath_parts) > 1:
201
 
            if relpath_parts[0] == '':
202
 
                raise ValueError("path %r within branch %r seems to be absolute"
203
 
                                 % (relpath, self._path))
204
 
        basepath = self._path.split('/')
 
199
        if relpath.startswith('/'):
 
200
            basepath = []
 
201
        else:
 
202
            basepath = self._path.split('/')
205
203
        if len(basepath) > 0 and basepath[-1] == '':
206
204
            basepath = basepath[:-1]
207
 
        for p in relpath_parts:
 
205
        for p in relpath.split('/'):
208
206
            if p == '..':
209
207
                if len(basepath) == 0:
210
208
                    # In most filesystems, a request for the parent
307
305
        abspath = self._abspath(relpath)
308
306
        tmp_abspath = '%s.tmp.%.9f.%d.%d' % (abspath, time.time(),
309
307
                        os.getpid(), random.randint(0,0x7FFFFFFF))
310
 
        if not hasattr(fp, 'read'):
 
308
        if getattr(fp, 'read', None) is None:
311
309
            fp = StringIO(fp)
312
310
        try:
313
311
            mutter("FTP put: %s", abspath)