29
30
from bzrlib.tests import TestCaseWithTransport
30
31
from bzrlib.tests import (
36
from bzrlib.tests.features import (
36
39
from bzrlib.tests.blackbox import test_switch
37
40
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
38
41
from bzrlib.tests.script import run_script
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 standalone tree (format: development-colo)\n""",
75
self.assertEqual('', err)
76
out, err = self.run_bzr(
77
'branch --use-existing-dir 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)
64
84
def test_branch_broken_pack(self):
65
85
"""branching with a corrupted pack file."""
66
86
self.example_branch('a')
67
#now add some random corruption
68
fname = 'a/.bzr/repository/packs/' + os.listdir('a/.bzr/repository/packs')[0]
88
packs_dir = 'a/.bzr/repository/packs/'
89
fname = packs_dir + os.listdir(packs_dir)[0]
69
90
with open(fname, 'rb+') as f:
91
# Start from the end of the file to avoid choosing a place bigger
92
# than the file itself.
93
f.seek(-5, os.SEEK_END)
95
f.seek(-5, os.SEEK_END)
96
# Make sure we inject a value different than the one we just read
101
f.write(corrupt) # make sure we corrupt something
72
102
self.run_bzr_error(['Corruption while decompressing repository file'],
73
103
'branch a b', retcode=3)
148
178
def make_shared_tree(path):
149
179
shared_repo.bzrdir.root_transport.mkdir(path)
150
shared_repo.bzrdir.create_branch_convenience('repo/' + path)
180
controldir.ControlDir.create_branch_convenience('repo/' + path)
151
181
return WorkingTree.open('repo/' + path)
152
182
tree_a = make_shared_tree('a')
153
183
self.build_tree(['repo/a/file'])
287
317
builder = self.make_branch_builder('source')
288
318
source = fixtures.build_branch_with_non_ancestral_rev(builder)
289
319
source.tags.set_tag('tag-a', 'rev-2')
320
source.get_config().set_user_option('branch.fetch_tags', 'True')
290
321
# Now source has a tag not in its ancestry. Make a branch from it.
291
322
self.run_bzr('branch source new-branch')
292
323
new_branch = branch.Branch.open('new-branch')
332
363
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
333
364
self.assertEqual('', out)
334
self.assertEqual('Branched 2 revision(s).\n',
365
self.assertEqual('Branched 2 revisions.\n',
336
367
# it should have preserved the branch format, and so it should be
337
368
# capable of supporting stacking, but not actually have a stacked_on
438
469
# being too low. If rpc_count increases, more network roundtrips have
439
470
# become necessary for this use case. Please do not adjust this number
440
471
# upwards without agreement from bzr's network support maintainers.
441
self.assertLength(36, self.hpss_calls)
472
self.assertLength(39, self.hpss_calls)
443
474
def test_branch_from_trivial_branch_streaming_acceptance(self):
444
475
self.setup_smart_server_with_call_log()
453
484
# being too low. If rpc_count increases, more network roundtrips have
454
485
# become necessary for this use case. Please do not adjust this number
455
486
# upwards without agreement from bzr's network support maintainers.
456
self.assertLength(9, self.hpss_calls)
487
self.assertLength(10, self.hpss_calls)
458
489
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
459
490
self.setup_smart_server_with_call_log()
473
504
# being too low. If rpc_count increases, more network roundtrips have
474
505
# become necessary for this use case. Please do not adjust this number
475
506
# upwards without agreement from bzr's network support maintainers.
476
self.assertLength(14, self.hpss_calls)
507
self.assertLength(15, self.hpss_calls)
478
509
def test_branch_from_branch_with_tags(self):
479
510
self.setup_smart_server_with_call_log()
480
511
builder = self.make_branch_builder('source')
481
512
source = fixtures.build_branch_with_non_ancestral_rev(builder)
513
source.get_config().set_user_option('branch.fetch_tags', 'True')
482
514
source.tags.set_tag('tag-a', 'rev-2')
483
515
source.tags.set_tag('tag-missing', 'missing-rev')
484
516
# Now source has a tag not in its ancestry. Make a branch from it.
489
521
# being too low. If rpc_count increases, more network roundtrips have
490
522
# become necessary for this use case. Please do not adjust this number
491
523
# upwards without agreement from bzr's network support maintainers.
492
self.assertLength(9, self.hpss_calls)
524
self.assertLength(10, self.hpss_calls)
494
526
def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
495
527
self.setup_smart_server_with_call_log()
557
589
$ bzr checkout %(option)s repo/trunk checkout
559
591
$ bzr branch --switch ../repo/trunk ../repo/branched
560
2>Branched 0 revision(s).
592
2>Branched 0 revisions.
561
593
2>Tree is up to date at revision 0.
562
594
2>Switched to branch:...branched...