~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

[merge] sftp fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
 
288
288
    def relpath(self, abspath):
289
289
        username, password, host, port, path = self._split_url(abspath)
290
 
        if (username != self._username or host != self._host or
291
 
            port != self._port or not path.startswith(self._path)):
292
 
            raise NonRelativePath('path %r is not under base URL %r'
293
 
                           % (abspath, self.base))
 
290
        error = []
 
291
        if (username != self._username):
 
292
            error.append('username mismatch')
 
293
        if (host != self._host):
 
294
            error.append('host mismatch')
 
295
        if (port != self._port):
 
296
            error.append('port mismatch')
 
297
        if (not path.startswith(self._path)):
 
298
            error.append('path mismatch')
 
299
        if error:
 
300
            raise NonRelativePath('path %r is not under base URL %r: %s'
 
301
                           % (abspath, self.base, ', '.join(error)))
294
302
        pl = len(self._path)
295
303
        return path[pl:].lstrip('/')
296
304
 
578
586
        netloc = urllib.quote(self._host)
579
587
        if self._username is not None:
580
588
            netloc = '%s@%s' % (urllib.quote(self._username), netloc)
581
 
        if self._port not in (None, 22):
 
589
        if self._port is not None:
582
590
            netloc = '%s:%d' % (netloc, self._port)
583
591
 
584
592
        return urlparse.urlunparse(('sftp', netloc, path, '', '', ''))
621
629
    def _parse_url(self, url):
622
630
        (self._username, self._password,
623
631
         self._host, self._port, self._path) = self._split_url(url)
624
 
        if self._port is None:
625
 
            self._port = 22
626
632
 
627
633
    def _sftp_connect(self):
628
634
        """Connect to the remote sftp server.