17
17
from cStringIO import StringIO
19
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
20
19
from bzrlib.lazy_import import lazy_import
21
20
lazy_import(globals(), """
22
21
from bzrlib import (
23
transport as _mod_transport,
26
26
from bzrlib.bundle import serializer as _serializer
27
27
from bzrlib.merge_directive import MergeDirective
28
from bzrlib.transport import (
29
do_catching_redirections,
28
from bzrlib.i18n import gettext
33
30
from bzrlib.trace import note
36
@deprecated_function(deprecated_in((1, 12, 0)))
37
def read_bundle_from_url(url):
38
return read_mergeable_from_url(url, _do_directive=False)
41
33
def read_mergeable_from_url(url, _do_directive=True, possible_transports=None):
42
34
"""Read mergable object from a given URL.
44
36
:return: An object supporting get_target_revision. Raises NotABundle if
45
37
the target is not a mergeable type.
47
child_transport = get_transport(url,
39
child_transport = _mod_transport.get_transport(url,
48
40
possible_transports=possible_transports)
49
41
transport = child_transport.clone('..')
50
42
filename = transport.relpath(child_transport.base)
62
54
url, filename = urlutils.split(exception.target,
63
55
exclude_trailing_slash=False)
65
raise errors.NotABundle('A directory cannot be a bundle')
66
return get_transport(url)
57
raise errors.NotABundle(gettext('A directory cannot be a bundle'))
58
return _mod_transport.get_transport_from_url(url)
69
bytef, transport = do_catching_redirections(get_bundle, transport,
61
bytef, transport = _mod_transport.do_catching_redirections(
62
get_bundle, transport, redirected_transport)
71
63
except errors.TooManyRedirections:
72
64
raise errors.NotABundle(transport.clone(filename).base)
73
65
except (errors.ConnectionReset, errors.ConnectionError), e: