29
30
from bzrlib.tests import TestCaseWithTransport
30
31
from bzrlib.tests import (
35
from bzrlib.tests.features import (
36
38
from bzrlib.tests.blackbox import test_switch
37
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
43
45
class TestBranch(TestCaseWithTransport):
45
def example_branch(self, path='.'):
46
tree = self.make_branch_and_tree(path)
47
def example_branch(self, path='.', format=None):
48
tree = self.make_branch_and_tree(path, format=format)
47
49
self.build_tree_contents([(path + '/hello', 'foo')])
49
51
tree.commit(message='setup')
50
52
self.build_tree_contents([(path + '/goodbye', 'baz')])
51
53
tree.add('goodbye')
52
54
tree.commit(message='setup')
54
57
def test_branch(self):
55
58
"""Branch from one branch to another."""
61
64
self.assertFalse(b._transport.has('branch-name'))
62
65
b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
67
def test_into_colocated(self):
68
"""Branch from a branch into a colocated branch."""
69
self.example_branch('a')
70
out, err = self.run_bzr(
71
'init --format=development-colo file:b,branch=orig')
73
"""Created a lightweight checkout (format: development-colo)\n""",
75
self.assertEqual('', err)
76
out, err = self.run_bzr(
77
'branch a file:b,branch=thiswasa')
78
self.assertEqual('', out)
79
self.assertEqual('Branched 2 revisions.\n', err)
80
out, err = self.run_bzr('branches b')
81
self.assertEqual(" orig\n thiswasa\n", out)
82
self.assertEqual('', err)
83
out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
84
self.assertEqual('', out)
85
self.assertEqual('bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
87
def test_from_colocated(self):
88
"""Branch from a colocated branch into a regular branch."""
89
tree = self.example_branch('a', format='development-colo')
90
tree.bzrdir.create_branch(name='somecolo')
91
out, err = self.run_bzr('branch %s,branch=somecolo' %
92
local_path_to_url('a'))
93
self.assertEqual('', out)
94
self.assertEqual('Branched 0 revisions.\n', err)
95
self.assertPathExists("somecolo")
64
97
def test_branch_broken_pack(self):
65
98
"""branching with a corrupted pack file."""
66
99
self.example_branch('a')
158
191
def make_shared_tree(path):
159
192
shared_repo.bzrdir.root_transport.mkdir(path)
160
shared_repo.bzrdir.create_branch_convenience('repo/' + path)
193
controldir.ControlDir.create_branch_convenience('repo/' + path)
161
194
return WorkingTree.open('repo/' + path)
162
195
tree_a = make_shared_tree('a')
163
196
self.build_tree(['repo/a/file'])
343
376
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
344
377
self.assertEqual('', out)
345
self.assertEqual('Branched 2 revision(s).\n',
378
self.assertEqual('Branched 2 revisions.\n',
347
380
# it should have preserved the branch format, and so it should be
348
381
# capable of supporting stacking, but not actually have a stacked_on
449
482
# being too low. If rpc_count increases, more network roundtrips have
450
483
# become necessary for this use case. Please do not adjust this number
451
484
# upwards without agreement from bzr's network support maintainers.
452
self.assertLength(37, self.hpss_calls)
485
self.assertLength(40, self.hpss_calls)
454
487
def test_branch_from_trivial_branch_streaming_acceptance(self):
455
488
self.setup_smart_server_with_call_log()
569
602
$ bzr checkout %(option)s repo/trunk checkout
571
604
$ bzr branch --switch ../repo/trunk ../repo/branched
572
2>Branched 0 revision(s).
605
2>Branched 0 revisions.
573
606
2>Tree is up to date at revision 0.
574
607
2>Switched to branch:...branched...