[MERGE] Calculate remote path relative to the shared medium in _SmartClient
John Arbash Meinel
john at arbash-meinel.com
Thu Jan 3 21:13:03 GMT 2008
John Arbash Meinel wrote:
Andrew-
Any response to this?
I realize that it isn't strictly *wrong* from a HTTP sense, though it
feels a bit "dirty".
I'm okay upgrading my vote to "tweak", but I was looking for feedback.
John
=:->
> John Arbash Meinel has voted comment.
> Status is now: Semi-approved
> Comment:
> As near as I can tell, the only strictly needed part is this:
> - return unescape(urlparse(transport.base)[2]).encode('utf8')
> + if self._shared_connection.base.startswith('bzr+http://'):
> + medium_base = self._shared_connection.base
> + else:
> + medium_base = urlutils.join(self._shared_connection.base, '/')
> +
> + return urlutils.relative_url(medium_base,
> transport.base).encode('utf8')
>
> I don't really understand why you need that "startswith()" check.
>
> The problem with leaving it POSTing to the original URL is when you give
> it a filename at the end of a branch.
>
> Specifically: bzr log http://bazaar-vcs.org/bzr/bzr.dev/bzr
>
> Should give you the log of just the changes to the 'bzr' file. But
> POSTing to http://bazaar-vcs.org/bzr/bzr.dev/bzr/.bzr/smart seems a
> little wrong (considering you are posting to a URL which is underneath a
> file.)
>
> I wouldn't think handling the connection would be a strict problem,
> since it should already be handled in the case that an HTTPTransport is
> cloned from itself.
>
> In my testing, to get bzr+http:// to work I only needed the client to be
> updated (I happen to have both of your patches, but I'm guessing this is
> the important one for the client).
>
>
> === modified file 'bzrlib/transport/remote.py'
> --- bzrlib/transport/remote.py 2007-11-19 13:44:25 +0000
> +++ bzrlib/transport/remote.py 2007-12-13 06:29:54 +0000
> @@ -102,7 +102,8 @@
> trace.mutter('hpss: Built a new medium: %s',
> medium.__class__.__name__)
> self._shared_connection = transport._SharedConnection(medium,
> - credentials)
> + credentials,
> + self.base)
>
> if _client is None:
> self._client = client._SmartClient(self.get_shared_medium())
> @@ -496,7 +497,7 @@
> """After connecting, HTTP Transport only deals in relative
> URLs."""
> # Adjust the relpath based on which URL this smart transport is
> # connected to.
> - http_base = urlutils.normalize_url(self._http_transport.base)
> + http_base = urlutils.normalize_url(self.get_smart_medium().base)
> url = urlutils.join(self.base[len('bzr+'):], relpath)
> url = urlutils.normalize_url(url)
> return urlutils.relative_url(http_base, url)
>
> ^- I also don't quite understand why you prefer
> "get_smart_medium().base". Especially since you had to switch
> _SharedConnection to start having a .base attribute.
More information about the bazaar
mailing list