[MERGE] external_references repository patch.

Robert Collins robertc at robertcollins.net
Tue Feb 19 09:31:12 GMT 2008


On Tue, 2008-02-19 at 20:04 +1100, Andrew Bennetts wrote:
> bb:tweak
> 
> Robert Collins wrote:
> [...]
> > === modified file 'bzrlib/remote.py'
> > --- bzrlib/remote.py	2008-02-07 03:47:24 +0000
> > +++ bzrlib/remote.py	2008-02-12 05:17:25 +0000
> > @@ -148,16 +148,29 @@
> >                  
> >      def open_repository(self):
> >          path = self._path_for_remote_call(self._client)
> > -        response = self._client.call('BzrDir.find_repository', path)
> > +        verb = 'BzrDir.find_repositoryV2'
> > +        response = self._client.call(verb, path)
> > +        if (response == ('error', "Generic bzr smart protocol error: "
> > +                "bad request '%s'" % verb) or
> > +              response == ('error', "Generic bzr smart protocol error: "
> > +                "bad request u'%s'" % verb)):
> > +            verb = 'BzrDir.find_repository'
> 
> You should use self._response_is_unknown_method for this.

Does that exist now? I added *a* version of it on a different Remote
object.

> > +            response = self._client.call(verb, path)
> >          assert response[0] in ('ok', 'norepository'), \
> >              'unexpected response code %s' % (response,)
> >          if response[0] == 'norepository':
> >              raise errors.NoRepositoryPresent(self)
> > -        assert len(response) == 4, 'incorrect response length %s' % (response,)
> > +        if verb == 'BzrDir.find_repository':
> > +            # servers that don't support the V2 method don't support external
> > +            # references either.
> > +            response = response + ('no', )
> > +        assert len(response) == 5, 'incorrect response length %s' % (response,)
> 
> This is a pre-existing flaw, but this really should be raising
> SmartProtocolError or similar if the data off the network is malformed, rather
> than relying on an assert statement.
> 
> (Hmm.  It may be worth having a different error to SmartProtocolError so we can
> distinguish between serialisation errors and erroneous responses that are
> correctly serialised; i.e. "the protocol encoding went wrong" vs. "the
> request/response handler went wrong"...)

Agreed. Wishlist?

> >          if response[1] == '':
> >              format = RemoteRepositoryFormat()
> >              format.rich_root_data = (response[2] == 'yes')
> >              format.supports_tree_reference = (response[3] == 'yes')
> > +            # No wire format to check this yet.
> > +            format.supports_external_lookups = (response[4] == 'yes')
> 
> I'm not sure what that comment means.  What's “this”?

Its stale, I wrote this patch in phases, starting with _real_repository
lookups. Will fix.

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080219/34cf386c/attachment.pgp 


More information about the bazaar mailing list