18
18
"""Tests of bound branches (binding, unbinding, commit, etc) command."""
21
from cStringIO import StringIO
23
22
from bzrlib import (
28
26
from bzrlib.branch import Branch
29
from bzrlib.bzrdir import (BzrDir, BzrDirFormat, BzrDirMetaFormat1)
30
from bzrlib.osutils import getcwd
27
from bzrlib.bzrdir import BzrDir
31
28
from bzrlib.tests import script
32
import bzrlib.urlutils as urlutils
33
from bzrlib.workingtree import WorkingTree
36
class TestLegacyFormats(tests.TestCaseWithTransport):
39
super(TestLegacyFormats, self).setUp()
40
self.build_tree(['master/', 'child/'])
41
self.make_branch_and_tree('master')
42
self.make_branch_and_tree('child',
43
format=bzrdir.format_registry.make_bzrdir('weave'))
46
def test_bind_format_6_bzrdir(self):
47
# bind on a format 6 bzrdir should error
48
out,err = self.run_bzr('bind ../master', retcode=3)
49
self.assertEqual('', out)
50
# TODO: jam 20060427 Probably something like this really should
51
# print out the actual path, rather than the URL
52
cwd = urlutils.local_path_to_url(getcwd())
53
self.assertEqual('bzr: ERROR: To use this feature you must '
54
'upgrade your branch at %s/.\n' % cwd, err)
56
def test_unbind_format_6_bzrdir(self):
57
# bind on a format 6 bzrdir should error
58
out,err = self.run_bzr('unbind', retcode=3)
59
self.assertEqual('', out)
60
cwd = urlutils.local_path_to_url(getcwd())
61
self.assertEqual('bzr: ERROR: To use this feature you must '
62
'upgrade your branch at %s/.\n' % cwd, err)
65
31
class TestBoundBranches(tests.TestCaseWithTransport):
84
50
def check_revno(self, val, loc='.'):
86
val, len(BzrDir.open(loc).open_branch().revision_history()))
52
val, BzrDir.open(loc).open_branch().last_revision_info()[0])
88
54
def test_simple_binding(self):
89
55
tree = self.make_branch_and_tree('base')
263
229
child_tree.commit(message='merged')
264
230
self.check_revno(3)
266
# After binding, the revision history should be unaltered
268
base_history = base_branch.revision_history()
269
child_history = child_branch.revision_history()
233
child_tree.branch.last_revision(),
234
base_tree.branch.last_revision())
271
236
def test_bind_parent_ahead(self):
272
237
base_tree = self.create_branches()[0]
367
332
self.build_tree_contents([('other/c', 'file c\n')])
368
333
other_tree.add('c')
369
334
other_tree.commit(message='adding c')
370
new_rev_id = other_branch.revision_history()[-1]
335
new_rev_id = other_branch.last_revision()
372
337
child_tree.merge_from_branch(other_branch)
374
self.failUnlessExists('child/c')
339
self.assertPathExists('child/c')
375
340
self.assertEqual([new_rev_id], child_tree.get_parent_ids()[1:])
377
342
# Make sure the local branch has the installed revision