/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-01 05:11:40 UTC
  • mfrom: (1551.14.13 mergedirective)
  • Revision ID: pqm@pqm.ubuntu.com-20070401051140-280aed4369df0386
merge and pull support merge directives

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
from StringIO import StringIO
 
18
 
17
19
from bzrlib.lazy_import import lazy_import
18
20
lazy_import(globals(), """
19
21
from bzrlib import (
26
28
 
27
29
 
28
30
def read_bundle_from_url(url):
29
 
    """Read a bundle from a given URL.
30
 
 
31
 
    :return: A BundleReader, may raise NotABundle if the target 
32
 
            is not a proper bundle.
 
31
    return read_mergeable_from_url(url, _do_directive=False)
 
32
 
 
33
def read_mergeable_from_url(url, _do_directive=True):
 
34
    """Read mergable object from a given URL.
 
35
 
 
36
    :return: An object supporting get_target_revision.  Raises NotABundle if
 
37
        the target is not a mergeable type.
33
38
    """
 
39
    from bzrlib.merge_directive import MergeDirective
34
40
    url = urlutils.normalize_url(url)
35
41
    url, filename = urlutils.split(url, exclude_trailing_slash=False)
36
42
    if not filename:
44
50
    try:
45
51
        t = _get_transport(url)
46
52
        f = t.get(filename)
47
 
        return _serializer.read_bundle(f)
 
53
        if _do_directive:
 
54
            directive = MergeDirective.from_lines(f.readlines())
 
55
            return directive
 
56
        else:
 
57
            return _serializer.read_bundle(f)
48
58
    except (errors.TransportError, errors.PathError), e:
49
59
        raise errors.NotABundle(str(e))
50
60
    except (IOError,), e:
56
66
        # StubSFTPServer does fail during get() (because of prefetch) 
57
67
        # so it has an opportunity to translate the error.
58
68
        raise errors.NotABundle(str(e))
59
 
 
 
69
    except errors.NotAMergeDirective:
 
70
        f.seek(0)
 
71
        return _serializer.read_bundle(f)