~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
 
 
19
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
19
20
from bzrlib.lazy_import import lazy_import
20
21
lazy_import(globals(), """
21
22
from bzrlib import (
22
23
    errors,
23
 
    transport as _mod_transport,
24
24
    urlutils,
25
25
    )
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,
 
30
    get_transport,
 
31
    )
28
32
""")
29
33
from bzrlib.trace import note
30
34
 
31
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
 
32
41
def read_mergeable_from_url(url, _do_directive=True, possible_transports=None):
33
42
    """Read mergable object from a given URL.
34
43
 
35
44
    :return: An object supporting get_target_revision.  Raises NotABundle if
36
45
        the target is not a mergeable type.
37
46
    """
38
 
    child_transport = _mod_transport.get_transport(url,
 
47
    child_transport = get_transport(url,
39
48
        possible_transports=possible_transports)
40
49
    transport = child_transport.clone('..')
41
50
    filename = transport.relpath(child_transport.base)
54
63
                                       exclude_trailing_slash=False)
55
64
        if not filename:
56
65
            raise errors.NotABundle('A directory cannot be a bundle')
57
 
        return _mod_transport.get_transport_from_url(url)
 
66
        return get_transport(url)
58
67
 
59
68
    try:
60
 
        bytef, transport = _mod_transport.do_catching_redirections(
61
 
            get_bundle, transport, redirected_transport)
 
69
        bytef, transport = do_catching_redirections(get_bundle, transport,
 
70
                                                    redirected_transport)
62
71
    except errors.TooManyRedirections:
63
72
        raise errors.NotABundle(transport.clone(filename).base)
64
73
    except (errors.ConnectionReset, errors.ConnectionError), e: