[MERGE][0.90][Bug 133965] PathNotChild, port mismatch with "bzr info" for bzr:// smartserver

John Arbash Meinel john at arbash-meinel.com
Fri Aug 24 15:21:24 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> On (24/08/07 06:50), Robert Collins wrote:
>> This is clearly wrong.
>>
>> The right way to handle this is to use the default port number if none
>> has been explicitly provided.
>>
>> E.g. to do a comparison with http, you need to supply 80, for https 443,
>> etc.
> 
> Hi,
> 
> I'm not really sure how to proceed, so I have recorded my understanding
> in the hope that it will help someone to see the light.
> 
> Ok, for explicit ports in the url everything is fine, so we only need to
> consider default ports.
> 
> When the user provides a url they do not put a port in it, and so
> _split_url returns None for the port.
> 
> For most transports self._port is None in the default case, and so this
> works out fine.
> 
> For bzr:// if the port is None when the transport is created then
> self._port is set to BZR_DEFAULT_PORT. This then means that the url that
> was used to create the transport is no longer a child of it, as the
> ports differ, giving rise to the bug.
> 
> Why does the bzr:// transport differ here in that it explicitly sets
> its port to the default?
> 
> Is the best way to change all transports to explicitly set the default
> port? Can the default be dropped from bzr://?
> 
> I'm not going to have time to complete this tonight, so if someone can
> come up with a fix I would appreciate it.
> 
> Thanks,
> 
> James
> 


Well, it seems like this would be the simple fix:
=== modified file 'bzrlib/transport/remote.py'
- --- bzrlib/transport/remote.py  2007-07-30 14:36:04 +0000
+++ bzrlib/transport/remote.py  2007-08-24 14:20:41 +0000
@@ -443,9 +443,10 @@

     def _build_medium(self):
         assert self.base.startswith('bzr://')
- -        if self._port is None:
- -            self._port = BZR_DEFAULT_PORT
- -        return medium.SmartTCPClientMedium(self._host, self._port), None
+        port = self._port
+        if port is None:
+            port = BZR_DEFAULT_PORT
+        return medium.SmartTCPClientMedium(self._host, port), None


 class RemoteSSHTransport(RemoteTransport):

Basically, just create a local variable to hold the real port, and don't change
the self._port value.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzuljJdeBCYSNAAMRAuqPAJ0fdF+/0vpwnI12KplKfoIMknlm5gCfZvjI
OOndY1Hjvbe9Vlp0CvyKJSg=
=x+Jo
-----END PGP SIGNATURE-----



More information about the bazaar mailing list