1
# Copyright (C) 2006 Canonical Ltd
1
# Copyright (C) 2006 by 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):
40
45
self.build_tree(['tree/', 'tree/a', 'tree/subdir/'])
42
47
format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
44
50
bzrdir = format.initialize('tree')
45
51
repo = bzrdir.create_repository()
46
52
branch = repo.bzrdir.create_branch()
52
58
out = cStringIO.StringIO()
53
59
rev_ids = write_bundle(wt.branch.repository,
54
wt.get_parent_ids()[0], 'null:', out)
60
wt.last_revision(), None, out)
56
if self.get_transport().is_readonly():
62
if self._transport.is_readonly():
57
63
f = open('test_bundle', 'wb')
58
64
f.write(out.getvalue())
61
self.get_transport().put_file('test_bundle', out)
67
self._transport.put('test_bundle', out)
62
68
self.log('Put to: %s', self.get_url('test_bundle'))
65
71
def test_read_bundle_from_url(self):
66
self._captureVar('BZR_NO_SMART_VFS', None)
67
72
wt = self.create_test_bundle()
70
76
info = bzrlib.bundle.read_bundle_from_url(
71
unicode(self.get_url('test_bundle')))
72
revision = info.real_revisions[-1]
73
self.assertEqual('commit-1', revision.revision_id)
77
self.get_url('test_bundle'))
78
bundle_tree = info.revision_tree(wt.branch.repository, info.target)
79
self.assertEqual('commit-1', bundle_tree.revision_id)
75
81
def test_read_fail(self):
76
82
# Trying to read from a directory, or non-bundle file
77
83
# should fail with NotABundle
78
self._captureVar('BZR_NO_SMART_VFS', None)
79
84
wt = self.create_test_bundle()