[PATCH] Re: any more sftp fixes?
Matthieu Moy
Matthieu.Moy at imag.fr
Wed Nov 30 23:31:34 GMT 2005
John A Meinel <john at arbash-meinel.com> writes:
> The changes are available here:
> http://bzr.arbash-meinel.com/branches/bzr/sftp-fix/
Still doesn't work for me.
First, the error message for non-relative path is unclear, because the
error can come from a different port number, different host, or
different user.
The following patch gives a more detailed error message.
Moreover, in relpath(self, abspath) too, abspath does not necessarily
contain a port number, so _split_url might return None for the port.
The patch also fixes this by setting the port to 22 in _split_url()
instead of _parse_url(). That seems to be sufficient for me.
However, pushing gives me an error message which I think should be a
warning.
$ ~/dev/sftp-fix/bzr push sftp://moy@localhost/%2ftmp/foobar
Password:
bzr: ERROR: No WorkingTree exists for {'base': 'sftp://moy@localhost/%2Ftmp/foobar'}(base).
I suppose I should read this as
"dear user,
I'm sorry to inform you that bzr is not (yet ?) able to update remote
working trees when doing a push. Please, run "bzr revert" from the
remote location if you want to do so.
Best Regards,
The bzr team"
;-).
--
Matthieu
--- a/home/moy/dev/sftp-fix/bzrlib/transport/sftp.py
+++ b/home/moy/dev/sftp-fix/bzrlib/transport/sftp.py
@@ -282,10 +282,18 @@
def relpath(self, abspath):
username, password, host, port, path =
self._split_url(abspath)
- if (username != self._username or host != self._host or
- port != self._port or not path.startswith(self._path)):
+ if (username != self._username):
+ raise NonRelativePath('User %s different from %s'
+ % (username, self._username))
+ if (host != self._host):
+ raise NonRelativePath('Host %s different from %s'
+ % (host, self._host))
+ if (port != self._port):
+ raise NonRelativePath('Port %s different from %s'
+ % (port, self._port))
+ if (not path.startswith(self._path)):
raise NonRelativePath('path %r is not under base URL %r'
- % (abspath, self.base))
+ % (abspath, self.base))
pl = len(self._path)
return path[pl:].lstrip('/')
@@ -610,14 +618,14 @@
# see draft-ietf-secsh-scp-sftp-ssh-uri-03.txt
if path.startswith('/'):
path = path[1:]
+ if port is None:
+ port = 22
return (username, password, host, port, path)
def _parse_url(self, url):
(self._username, self._password,
self._host, self._port, self._path) = self._split_url(url)
- if self._port is None:
- self._port = 22
def _sftp_connect(self):
"""Connect to the remote sftp server.
More information about the bazaar
mailing list