~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Martin Pool
  • Date: 2007-04-01 06:19:16 UTC
  • mfrom: (2323.5.20 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: mbp@sourcefrog.net-20070401061916-plpgsxdf8g7gll9o
Merge 0.15 final release back to trunk, including: recommend upgrades of old workingtrees, handle multiple http redirections, some dirstate fixes, 

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    urlutils,
24
24
    )
25
25
from bzrlib.bundle import serializer as _serializer
26
 
from bzrlib.transport import get_transport as _get_transport
 
26
from bzrlib.transport import (
 
27
    do_catching_redirections,
 
28
    get_transport,
 
29
    )
27
30
""")
 
31
from bzrlib.trace import note
28
32
 
29
33
 
30
34
def read_bundle_from_url(url):
48
52
    # Some transports cannot detect that we are trying to read a
49
53
    # directory until we actually issue read() on the handle.
50
54
    try:
51
 
        t = _get_transport(url)
52
 
        f = t.get(filename)
 
55
        transport = get_transport(url)
 
56
 
 
57
        def get_bundle(transport):
 
58
            return transport.get(filename)
 
59
 
 
60
        def redirected_transport(transport, exception, redirection_notice):
 
61
            note(redirection_notice)
 
62
            url, filename = urlutils.split(exception.target,
 
63
                                           exclude_trailing_slash=False)
 
64
            if not filename:
 
65
                raise errors.NotABundle('A directory cannot be a bundle')
 
66
            return get_transport(url)
 
67
 
 
68
        try:
 
69
            f = do_catching_redirections(get_bundle, transport,
 
70
                                         redirected_transport)
 
71
        except errors.TooManyRedirections:
 
72
            raise errors.NotABundle(str(url))
 
73
 
53
74
        if _do_directive:
54
75
            directive = MergeDirective.from_lines(f.readlines())
55
76
            return directive