1
# Copyright (C) 2006-2011 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Black-box tests for bzr branch."""
27
revision as _mod_revision,
29
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
30
from bzrlib.tests import TestCaseWithTransport
31
from bzrlib.tests import (
35
from bzrlib.tests.features import (
38
from bzrlib.tests.blackbox import test_switch
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
40
from bzrlib.tests.script import run_script
41
from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
42
from bzrlib.workingtree import WorkingTree
45
class TestBranch(TestCaseWithTransport):
47
def example_branch(self, path='.', format=None):
48
tree = self.make_branch_and_tree(path, format=format)
49
self.build_tree_contents([(path + '/hello', 'foo')])
51
tree.commit(message='setup')
52
self.build_tree_contents([(path + '/goodbye', 'baz')])
54
tree.commit(message='setup')
57
def test_branch(self):
58
"""Branch from one branch to another."""
59
self.example_branch('a')
60
self.run_bzr('branch a b')
61
b = branch.Branch.open('b')
62
self.run_bzr('branch a c -r 1')
63
# previously was erroneously created by branching
64
self.assertFalse(b._transport.has('branch-name'))
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")
97
def test_branch_broken_pack(self):
98
"""branching with a corrupted pack file."""
99
self.example_branch('a')
100
# add some corruption
101
packs_dir = 'a/.bzr/repository/packs/'
102
fname = packs_dir + os.listdir(packs_dir)[0]
103
with open(fname, 'rb+') as f:
104
# Start from the end of the file to avoid choosing a place bigger
105
# than the file itself.
106
f.seek(-5, os.SEEK_END)
108
f.seek(-5, os.SEEK_END)
109
# Make sure we inject a value different than the one we just read
114
f.write(corrupt) # make sure we corrupt something
115
self.run_bzr_error(['Corruption while decompressing repository file'],
116
'branch a b', retcode=3)
118
def test_branch_switch_no_branch(self):
119
# No branch in the current directory:
120
# => new branch will be created, but switch fails
121
self.example_branch('a')
122
self.make_repository('current')
123
self.run_bzr_error(['No WorkingTree exists for'],
124
'branch --switch ../a ../b', working_dir='current')
125
a = branch.Branch.open('a')
126
b = branch.Branch.open('b')
127
self.assertEqual(a.last_revision(), b.last_revision())
129
def test_branch_switch_no_wt(self):
130
# No working tree in the current directory:
131
# => new branch will be created, but switch fails and the current
132
# branch is unmodified
133
self.example_branch('a')
134
self.make_branch('current')
135
self.run_bzr_error(['No WorkingTree exists for'],
136
'branch --switch ../a ../b', working_dir='current')
137
a = branch.Branch.open('a')
138
b = branch.Branch.open('b')
139
self.assertEqual(a.last_revision(), b.last_revision())
140
work = branch.Branch.open('current')
141
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
143
def test_branch_switch_no_checkout(self):
144
# Standalone branch in the current directory:
145
# => new branch will be created, but switch fails and the current
146
# branch is unmodified
147
self.example_branch('a')
148
self.make_branch_and_tree('current')
149
self.run_bzr_error(['Cannot switch a branch, only a checkout'],
150
'branch --switch ../a ../b', working_dir='current')
151
a = branch.Branch.open('a')
152
b = branch.Branch.open('b')
153
self.assertEqual(a.last_revision(), b.last_revision())
154
work = branch.Branch.open('current')
155
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
157
def test_branch_switch_checkout(self):
158
# Checkout in the current directory:
159
# => new branch will be created and checkout bound to the new branch
160
self.example_branch('a')
161
self.run_bzr('checkout a current')
162
out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
163
a = branch.Branch.open('a')
164
b = branch.Branch.open('b')
165
self.assertEqual(a.last_revision(), b.last_revision())
166
work = WorkingTree.open('current')
167
self.assertEndsWith(work.branch.get_bound_location(), '/b/')
168
self.assertContainsRe(err, "Switched to branch: .*/b/")
170
def test_branch_switch_lightweight_checkout(self):
171
# Lightweight checkout in the current directory:
172
# => new branch will be created and lightweight checkout pointed to
174
self.example_branch('a')
175
self.run_bzr('checkout --lightweight a current')
176
out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
177
a = branch.Branch.open('a')
178
b = branch.Branch.open('b')
179
self.assertEqual(a.last_revision(), b.last_revision())
180
work = WorkingTree.open('current')
181
self.assertEndsWith(work.branch.base, '/b/')
182
self.assertContainsRe(err, "Switched to branch: .*/b/")
184
def test_branch_only_copies_history(self):
185
# Knit branches should only push the history for the current revision.
186
format = bzrdir.BzrDirMetaFormat1()
187
format.repository_format = RepositoryFormatKnit1()
188
shared_repo = self.make_repository('repo', format=format, shared=True)
189
shared_repo.set_make_working_trees(True)
191
def make_shared_tree(path):
192
shared_repo.bzrdir.root_transport.mkdir(path)
193
controldir.ControlDir.create_branch_convenience('repo/' + path)
194
return WorkingTree.open('repo/' + path)
195
tree_a = make_shared_tree('a')
196
self.build_tree(['repo/a/file'])
198
tree_a.commit('commit a-1', rev_id='a-1')
199
f = open('repo/a/file', 'ab')
200
f.write('more stuff\n')
202
tree_a.commit('commit a-2', rev_id='a-2')
204
tree_b = make_shared_tree('b')
205
self.build_tree(['repo/b/file'])
207
tree_b.commit('commit b-1', rev_id='b-1')
209
self.assertTrue(shared_repo.has_revision('a-1'))
210
self.assertTrue(shared_repo.has_revision('a-2'))
211
self.assertTrue(shared_repo.has_revision('b-1'))
213
# Now that we have a repository with shared files, make sure
214
# that things aren't copied out by a 'branch'
215
self.run_bzr('branch repo/b branch-b')
216
pushed_tree = WorkingTree.open('branch-b')
217
pushed_repo = pushed_tree.branch.repository
218
self.assertFalse(pushed_repo.has_revision('a-1'))
219
self.assertFalse(pushed_repo.has_revision('a-2'))
220
self.assertTrue(pushed_repo.has_revision('b-1'))
222
def test_branch_hardlink(self):
223
self.requireFeature(HardlinkFeature)
224
source = self.make_branch_and_tree('source')
225
self.build_tree(['source/file1'])
227
source.commit('added file')
228
out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
229
source_stat = os.stat('source/file1')
230
target_stat = os.stat('target/file1')
231
self.assertEqual(source_stat, target_stat)
233
def test_branch_files_from(self):
234
source = self.make_branch_and_tree('source')
235
self.build_tree(['source/file1'])
237
source.commit('added file')
238
out, err = self.run_bzr('branch source target --files-from source')
239
self.assertPathExists('target/file1')
241
def test_branch_files_from_hardlink(self):
242
self.requireFeature(HardlinkFeature)
243
source = self.make_branch_and_tree('source')
244
self.build_tree(['source/file1'])
246
source.commit('added file')
247
source.bzrdir.sprout('second')
248
out, err = self.run_bzr('branch source target --files-from second'
250
source_stat = os.stat('source/file1')
251
second_stat = os.stat('second/file1')
252
target_stat = os.stat('target/file1')
253
self.assertNotEqual(source_stat, target_stat)
254
self.assertEqual(second_stat, target_stat)
256
def test_branch_standalone(self):
257
shared_repo = self.make_repository('repo', shared=True)
258
self.example_branch('source')
259
self.run_bzr('branch --standalone source repo/target')
260
b = branch.Branch.open('repo/target')
261
expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
262
self.assertEqual(strip_trailing_slash(b.repository.base),
263
strip_trailing_slash(local_path_to_url(expected_repo_path)))
265
def test_branch_no_tree(self):
266
self.example_branch('source')
267
self.run_bzr('branch --no-tree source target')
268
self.assertPathDoesNotExist('target/hello')
269
self.assertPathDoesNotExist('target/goodbye')
271
def test_branch_into_existing_dir(self):
272
self.example_branch('a')
273
# existing dir with similar files but no .bzr dir
274
self.build_tree_contents([('b/',)])
275
self.build_tree_contents([('b/hello', 'bar')]) # different content
276
self.build_tree_contents([('b/goodbye', 'baz')])# same content
277
# fails without --use-existing-dir
278
out,err = self.run_bzr('branch a b', retcode=3)
279
self.assertEqual('', out)
280
self.assertEqual('bzr: ERROR: Target directory "b" already exists.\n',
283
self.run_bzr('branch a b --use-existing-dir')
285
self.assertPathExists('b/hello.moved')
286
self.assertPathDoesNotExist('b/godbye.moved')
287
# we can't branch into branch
288
out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
289
self.assertEqual('', out)
290
self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
292
def test_branch_bind(self):
293
self.example_branch('a')
294
out, err = self.run_bzr('branch a b --bind')
295
self.assertEndsWith(err, "New branch bound to a\n")
296
b = branch.Branch.open('b')
297
self.assertEndsWith(b.get_bound_location(), '/a/')
299
def test_branch_with_post_branch_init_hook(self):
301
branch.Branch.hooks.install_named_hook('post_branch_init',
303
self.assertLength(0, calls)
304
self.example_branch('a')
305
self.assertLength(1, calls)
306
self.run_bzr('branch a b')
307
self.assertLength(2, calls)
309
def test_checkout_with_post_branch_init_hook(self):
311
branch.Branch.hooks.install_named_hook('post_branch_init',
313
self.assertLength(0, calls)
314
self.example_branch('a')
315
self.assertLength(1, calls)
316
self.run_bzr('checkout a b')
317
self.assertLength(2, calls)
319
def test_lightweight_checkout_with_post_branch_init_hook(self):
321
branch.Branch.hooks.install_named_hook('post_branch_init',
323
self.assertLength(0, calls)
324
self.example_branch('a')
325
self.assertLength(1, calls)
326
self.run_bzr('checkout --lightweight a b')
327
self.assertLength(2, calls)
329
def test_branch_fetches_all_tags(self):
330
builder = self.make_branch_builder('source')
331
source = fixtures.build_branch_with_non_ancestral_rev(builder)
332
source.tags.set_tag('tag-a', 'rev-2')
333
source.get_config().set_user_option('branch.fetch_tags', 'True')
334
# Now source has a tag not in its ancestry. Make a branch from it.
335
self.run_bzr('branch source new-branch')
336
new_branch = branch.Branch.open('new-branch')
337
# The tag is present, and so is its revision.
338
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
339
new_branch.repository.get_revision('rev-2')
342
class TestBranchStacked(TestCaseWithTransport):
343
"""Tests for branch --stacked"""
345
def assertRevisionInRepository(self, repo_path, revid):
346
"""Check that a revision is in a repository, disregarding stacking."""
347
repo = bzrdir.BzrDir.open(repo_path).open_repository()
348
self.assertTrue(repo.has_revision(revid))
350
def assertRevisionNotInRepository(self, repo_path, revid):
351
"""Check that a revision is not in a repository, disregarding stacking."""
352
repo = bzrdir.BzrDir.open(repo_path).open_repository()
353
self.assertFalse(repo.has_revision(revid))
355
def assertRevisionsInBranchRepository(self, revid_list, branch_path):
356
repo = branch.Branch.open(branch_path).repository
357
self.assertEqual(set(revid_list),
358
repo.has_revisions(revid_list))
360
def test_branch_stacked_branch_not_stacked(self):
361
"""Branching a stacked branch is not stacked by default"""
363
trunk_tree = self.make_branch_and_tree('target',
365
trunk_tree.commit('mainline')
366
# and a branch from it which is stacked
367
branch_tree = self.make_branch_and_tree('branch',
369
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
370
# with some work on it
371
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
372
work_tree.commit('moar work plz')
373
work_tree.branch.push(branch_tree.branch)
374
# branching our local branch gives us a new stacked branch pointing at
376
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
377
self.assertEqual('', out)
378
self.assertEqual('Branched 2 revisions.\n',
380
# it should have preserved the branch format, and so it should be
381
# capable of supporting stacking, but not actually have a stacked_on
383
self.assertRaises(errors.NotStacked,
384
bzrdir.BzrDir.open('newbranch').open_branch().get_stacked_on_url)
386
def test_branch_stacked_branch_stacked(self):
387
"""Asking to stack on a stacked branch does work"""
389
trunk_tree = self.make_branch_and_tree('target',
391
trunk_revid = trunk_tree.commit('mainline')
392
# and a branch from it which is stacked
393
branch_tree = self.make_branch_and_tree('branch',
395
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
396
# with some work on it
397
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
398
branch_revid = work_tree.commit('moar work plz')
399
work_tree.branch.push(branch_tree.branch)
400
# you can chain branches on from there
401
out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
402
self.assertEqual('', out)
403
self.assertEqual('Created new stacked branch referring to %s.\n' %
404
branch_tree.branch.base, err)
405
self.assertEqual(branch_tree.branch.base,
406
branch.Branch.open('branch2').get_stacked_on_url())
407
branch2_tree = WorkingTree.open('branch2')
408
branch2_revid = work_tree.commit('work on second stacked branch')
409
work_tree.branch.push(branch2_tree.branch)
410
self.assertRevisionInRepository('branch2', branch2_revid)
411
self.assertRevisionsInBranchRepository(
412
[trunk_revid, branch_revid, branch2_revid],
415
def test_branch_stacked(self):
417
trunk_tree = self.make_branch_and_tree('mainline',
419
original_revid = trunk_tree.commit('mainline')
420
self.assertRevisionInRepository('mainline', original_revid)
421
# and a branch from it which is stacked
422
out, err = self.run_bzr(['branch', '--stacked', 'mainline',
424
self.assertEqual('', out)
425
self.assertEqual('Created new stacked branch referring to %s.\n' %
426
trunk_tree.branch.base, err)
427
self.assertRevisionNotInRepository('newbranch', original_revid)
428
new_branch = branch.Branch.open('newbranch')
429
self.assertEqual(trunk_tree.branch.base, new_branch.get_stacked_on_url())
431
def test_branch_stacked_from_smart_server(self):
432
# We can branch stacking on a smart server
433
self.transport_server = test_server.SmartTCPServer_for_testing
434
trunk = self.make_branch('mainline', format='1.9')
435
out, err = self.run_bzr(
436
['branch', '--stacked', self.get_url('mainline'), 'shallow'])
438
def test_branch_stacked_from_non_stacked_format(self):
439
"""The origin format doesn't support stacking"""
440
trunk = self.make_branch('trunk', format='pack-0.92')
441
out, err = self.run_bzr(
442
['branch', '--stacked', 'trunk', 'shallow'])
443
# We should notify the user that we upgraded their format
444
self.assertEqualDiff(
445
'Source repository format does not support stacking, using format:\n'
446
' Packs 5 (adds stacking support, requires bzr 1.6)\n'
447
'Source branch format does not support stacking, using format:\n'
449
'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
450
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
451
'Created new stacked branch referring to %s.\n' % (trunk.base,),
454
def test_branch_stacked_from_rich_root_non_stackable(self):
455
trunk = self.make_branch('trunk', format='rich-root-pack')
456
out, err = self.run_bzr(
457
['branch', '--stacked', 'trunk', 'shallow'])
458
# We should notify the user that we upgraded their format
459
self.assertEqualDiff(
460
'Source repository format does not support stacking, using format:\n'
461
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
462
'Source branch format does not support stacking, using format:\n'
464
'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
465
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
466
'Created new stacked branch referring to %s.\n' % (trunk.base,),
470
class TestSmartServerBranching(TestCaseWithTransport):
472
def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
473
self.setup_smart_server_with_call_log()
474
t = self.make_branch_and_tree('from')
475
for count in range(9):
476
t.commit(message='commit %d' % count)
477
self.reset_smart_call_log()
478
out, err = self.run_bzr(['branch', self.get_url('from'),
479
self.get_url('target')])
480
# This figure represent the amount of work to perform this use case. It
481
# is entirely ok to reduce this number if a test fails due to rpc_count
482
# being too low. If rpc_count increases, more network roundtrips have
483
# become necessary for this use case. Please do not adjust this number
484
# upwards without agreement from bzr's network support maintainers.
485
self.assertLength(40, self.hpss_calls)
487
def test_branch_from_trivial_branch_streaming_acceptance(self):
488
self.setup_smart_server_with_call_log()
489
t = self.make_branch_and_tree('from')
490
for count in range(9):
491
t.commit(message='commit %d' % count)
492
self.reset_smart_call_log()
493
out, err = self.run_bzr(['branch', self.get_url('from'),
495
# This figure represent the amount of work to perform this use case. It
496
# is entirely ok to reduce this number if a test fails due to rpc_count
497
# being too low. If rpc_count increases, more network roundtrips have
498
# become necessary for this use case. Please do not adjust this number
499
# upwards without agreement from bzr's network support maintainers.
500
self.assertLength(10, self.hpss_calls)
502
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
503
self.setup_smart_server_with_call_log()
504
t = self.make_branch_and_tree('trunk')
505
for count in range(8):
506
t.commit(message='commit %d' % count)
507
tree2 = t.branch.bzrdir.sprout('feature', stacked=True
509
local_tree = t.branch.bzrdir.sprout('local-working').open_workingtree()
510
local_tree.commit('feature change')
511
local_tree.branch.push(tree2.branch)
512
self.reset_smart_call_log()
513
out, err = self.run_bzr(['branch', self.get_url('feature'),
515
# This figure represent the amount of work to perform this use case. It
516
# is entirely ok to reduce this number if a test fails due to rpc_count
517
# being too low. If rpc_count increases, more network roundtrips have
518
# become necessary for this use case. Please do not adjust this number
519
# upwards without agreement from bzr's network support maintainers.
520
self.assertLength(15, self.hpss_calls)
522
def test_branch_from_branch_with_tags(self):
523
self.setup_smart_server_with_call_log()
524
builder = self.make_branch_builder('source')
525
source = fixtures.build_branch_with_non_ancestral_rev(builder)
526
source.get_config().set_user_option('branch.fetch_tags', 'True')
527
source.tags.set_tag('tag-a', 'rev-2')
528
source.tags.set_tag('tag-missing', 'missing-rev')
529
# Now source has a tag not in its ancestry. Make a branch from it.
530
self.reset_smart_call_log()
531
out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
532
# This figure represent the amount of work to perform this use case. It
533
# is entirely ok to reduce this number if a test fails due to rpc_count
534
# being too low. If rpc_count increases, more network roundtrips have
535
# become necessary for this use case. Please do not adjust this number
536
# upwards without agreement from bzr's network support maintainers.
537
self.assertLength(10, self.hpss_calls)
539
def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
540
self.setup_smart_server_with_call_log()
541
t = self.make_branch_and_tree('from')
542
for count in range(9):
543
t.commit(message='commit %d' % count)
544
self.reset_smart_call_log()
545
out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
547
# XXX: the number of hpss calls for this case isn't deterministic yet,
548
# so we can't easily assert about the number of calls.
549
#self.assertLength(XXX, self.hpss_calls)
550
# We can assert that none of the calls were readv requests for rix
551
# files, though (demonstrating that at least get_parent_map calls are
552
# not using VFS RPCs).
553
readvs_of_rix_files = [
554
c for c in self.hpss_calls
555
if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
556
self.assertLength(0, readvs_of_rix_files)
559
class TestRemoteBranch(TestCaseWithSFTPServer):
562
super(TestRemoteBranch, self).setUp()
563
tree = self.make_branch_and_tree('branch')
564
self.build_tree_contents([('branch/file', 'file content\n')])
566
tree.commit('file created')
568
def test_branch_local_remote(self):
569
self.run_bzr(['branch', 'branch', self.get_url('remote')])
570
t = self.get_transport()
571
# Ensure that no working tree what created remotely
572
self.assertFalse(t.has('remote/file'))
574
def test_branch_remote_remote(self):
575
# Light cheat: we access the branch remotely
576
self.run_bzr(['branch', self.get_url('branch'),
577
self.get_url('remote')])
578
t = self.get_transport()
579
# Ensure that no working tree what created remotely
580
self.assertFalse(t.has('remote/file'))
583
class TestDeprecatedAliases(TestCaseWithTransport):
585
def test_deprecated_aliases(self):
586
"""bzr branch can be called clone or get, but those names are deprecated.
590
for command in ['clone', 'get']:
592
$ bzr %(command)s A B
593
2>The command 'bzr %(command)s' has been deprecated in bzr 2.4. Please use 'bzr branch' instead.
594
2>bzr: ERROR: Not a branch...
598
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
600
def _checkout_and_branch(self, option=''):
601
self.script_runner.run_script(self, '''
602
$ bzr checkout %(option)s repo/trunk checkout
604
$ bzr branch --switch ../repo/trunk ../repo/branched
605
2>Branched 0 revisions.
606
2>Tree is up to date at revision 0.
607
2>Switched to branch:...branched...
610
bound_branch = branch.Branch.open_containing('checkout')[0]
611
master_branch = branch.Branch.open_containing('repo/branched')[0]
612
return (bound_branch, master_branch)
614
def test_branch_switch_parent_lightweight(self):
615
"""Lightweight checkout using bzr branch --switch."""
616
bb, mb = self._checkout_and_branch(option='--lightweight')
617
self.assertParent('repo/trunk', bb)
618
self.assertParent('repo/trunk', mb)
620
def test_branch_switch_parent_heavyweight(self):
621
"""Heavyweight checkout using bzr branch --switch."""
622
bb, mb = self._checkout_and_branch()
623
self.assertParent('repo/trunk', bb)
624
self.assertParent('repo/trunk', mb)