[rfc] Handling redirects properly.

Martin Pool mbp at canonical.com
Thu Jul 20 14:31:50 BST 2006


On 19 Jul 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> Basically, we would have something like:
> 
> try:
>   format = BzrDirFormat.find_format(a_transport)
> 
>   ...
> except RedirectRequested, e:
>   note('URL %s has been redirected to %s', e.old_url, e.new_url)
>   a_transport = get_transport(e.new_url)
> 
> I think this puts the functionality right about where we want it. So
> that when we go to open a new branch, we get redirected to the correct
> location.

I agree with the basic idea of raising an exception on redirects, and of
using them to switch entirely to a different directory.  If you would
like to go into this that would be great, but there are some things to
consider:

If we get a redirection at some later point the error will be uncaught
and terminate bzr.  We don't really expect to get redirections, but
still it would seem nice if the default behaviour is to just follow
them.

Presumably the actual error will be complaining about some sub-url
(e.g. .bzr/format) so you'll need to infer the right adjustment to the
url from that.  Or you could look at the base directory first, but that
might cause trouble if the server won't answer for directories.

This might relate to how we do http authentication?  It seems somewhat
similar: when we first try to access the url, we get an http error and
need to prompt for a username/password and retry.  (Not that you need to
handle it now, but it just occurred to me.)

Does this totally belong in BzrDirFormat.open?  Perhaps the general
approach of iterating until we actually find something should be put
into the transport, in an operation similar to "get physical path of x",
or "get canonical url".

-- 
Martin




More information about the bazaar mailing list