1
# Copyright (C) 2006 by Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
37
37
return bzrlib.urlutils.join(self._server.get_url(), relpath)
39
39
def create_test_bundle(self):
40
# Can't use self.get_transport() because that asserts that
41
# it is not readonly, so just skip tests where the server is readonly
42
self._transport = self.get_transport()
43
#if isinstance(self._transport, MemoryTransport):
45
40
self.build_tree(['tree/', 'tree/a', 'tree/subdir/'])
47
42
format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
50
44
bzrdir = format.initialize('tree')
51
45
repo = bzrdir.create_repository()
52
46
branch = repo.bzrdir.create_branch()
59
53
rev_ids = write_bundle(wt.branch.repository,
60
54
wt.get_parent_ids()[0], None, out)
62
if self._transport.is_readonly():
56
if self.get_transport().is_readonly():
63
57
f = open('test_bundle', 'wb')
64
58
f.write(out.getvalue())
67
self._transport.put_file('test_bundle', out)
61
self.get_transport().put_file('test_bundle', out)
68
62
self.log('Put to: %s', self.get_url('test_bundle'))
71
65
def test_read_bundle_from_url(self):
66
self._captureVar('BZR_NO_SMART_VFS', None)
72
67
wt = self.create_test_bundle()
76
70
info = bzrlib.bundle.read_bundle_from_url(
77
self.get_url('test_bundle'))
71
unicode(self.get_url('test_bundle')))
78
72
bundle_tree = info.revision_tree(wt.branch.repository, info.target)
79
73
self.assertEqual('commit-1', bundle_tree.revision_id)
81
75
def test_read_fail(self):
82
76
# Trying to read from a directory, or non-bundle file
83
77
# should fail with NotABundle
78
self._captureVar('BZR_NO_SMART_VFS', None)
84
79
wt = self.create_test_bundle()