~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2007-03-01 21:26:57 UTC
  • mto: (2323.7.1 redirection)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: v.ladeuil+lp@free.fr-20070301212657-bclmihdfnxgfy0sw
Take Aaron's review comments into account.

* bzrlib/transport/http/_urllib2_wrappers.py:
(HTTPRedirectHandler.http_error_301): Fix bug #88780.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._get): Fix doc string.

* bzrlib/transport/__init__.py:
(do_catching_redirections): Raise TooManyRedirections instead of
requiring an exception as a parameter.

* bzrlib/tests/test_http.py:
(TestHTTPRedirections.setUp): Simplified.
(TestHTTPRedirections.test_read_redirected_bundle_from_url): New test.
(TestDoCatchRedirections): New tests.

* bzrlib/tests/HTTPTestUtil.py:
(TestCaseWithRedirectedWebserver): New class factored out from
test_http.TestHTTPRedirections.

* bzrlib/errors.py:
(TooManyRedirections): New exception.

* bzrlib/bzrdir.py:
(BzrDir.open_from_transport.redirected): Catch TooManyRedirections.

* bzrlib/bundle/__init__.py:
(read_bundle_from_url.redirected_transport): Catch TooManyRedirections.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
        def redirected_transport(transport, exception, redirection_notice):
55
55
            note(redirection_notice)
56
 
            return get_transport(exception.get_target_url())
 
56
            url, filename = urlutils.split(exception.target,
 
57
                                           exclude_trailing_slash=False)
 
58
            if not filename:
 
59
                raise errors.NotABundle('A directory cannot be a bundle')
 
60
            return get_transport(url)
57
61
 
58
 
        f = do_catching_redirections(get_bundle, transport,
59
 
                                     redirected_transport,
60
 
                                     errors.NotABundle(str(url)))
 
62
        try:
 
63
            f = do_catching_redirections(get_bundle, transport,
 
64
                                         redirected_transport)
 
65
        except errors.TooManyRedirections:
 
66
            raise errors.NotABundle(str(url))
61
67
 
62
68
        return _serializer.read_bundle(f)
63
69
    except (errors.TransportError, errors.PathError), e: