[MERGE] Calculate remote path relative to the shared medium in _SmartClient

John Arbash Meinel john at arbash-meinel.com
Thu Dec 20 21:45:23 GMT 2007


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.


For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C20071214011937.GA26039%40steerpike.home.puzzling.org%3E



More information about the bazaar mailing list