~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Martin
  • Date: 2010-05-03 20:57:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5204.
  • Revision ID: gzlist@googlemail.com-20100503205739-n326zdvevv0rmruh
Retain original stack and error message when translating to ValueError in bencode

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
from cStringIO import StringIO
20
18
 
 
19
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
21
20
from bzrlib.lazy_import import lazy_import
22
21
lazy_import(globals(), """
23
22
from bzrlib import (
24
23
    errors,
25
 
    transport as _mod_transport,
26
24
    urlutils,
27
25
    )
28
26
from bzrlib.bundle import serializer as _serializer
29
27
from bzrlib.merge_directive import MergeDirective
30
 
from bzrlib.i18n import gettext
 
28
from bzrlib.transport import (
 
29
    do_catching_redirections,
 
30
    get_transport,
 
31
    )
31
32
""")
32
33
from bzrlib.trace import note
33
34
 
34
35
 
 
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)
 
39
 
 
40
 
35
41
def read_mergeable_from_url(url, _do_directive=True, possible_transports=None):
36
42
    """Read mergable object from a given URL.
37
43
 
38
44
    :return: An object supporting get_target_revision.  Raises NotABundle if
39
45
        the target is not a mergeable type.
40
46
    """
41
 
    child_transport = _mod_transport.get_transport(url,
 
47
    child_transport = get_transport(url,
42
48
        possible_transports=possible_transports)
43
49
    transport = child_transport.clone('..')
44
50
    filename = transport.relpath(child_transport.base)
56
62
        url, filename = urlutils.split(exception.target,
57
63
                                       exclude_trailing_slash=False)
58
64
        if not filename:
59
 
            raise errors.NotABundle(gettext('A directory cannot be a bundle'))
60
 
        return _mod_transport.get_transport_from_url(url)
 
65
            raise errors.NotABundle('A directory cannot be a bundle')
 
66
        return get_transport(url)
61
67
 
62
68
    try:
63
 
        bytef, transport = _mod_transport.do_catching_redirections(
64
 
            get_bundle, transport, redirected_transport)
 
69
        bytef, transport = do_catching_redirections(get_bundle, transport,
 
70
                                                    redirected_transport)
65
71
    except errors.TooManyRedirections:
66
72
        raise errors.NotABundle(transport.clone(filename).base)
67
73
    except (errors.ConnectionReset, errors.ConnectionError), e: