1
# Copyright (C) 2006-2012, 2016 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 brz branch."""
26
revision as _mod_revision,
29
from breezy.bzr import (
32
from breezy.bzr.knitrepo import RepositoryFormatKnit1
33
from breezy.tests import (
37
from breezy.tests.features import (
40
from breezy.tests.blackbox import test_switch
41
from breezy.tests.matchers import ContainsNoVfsCalls
42
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
43
from breezy.tests.script import run_script
44
from breezy.urlutils import local_path_to_url, strip_trailing_slash
45
from breezy.workingtree import WorkingTree
48
class TestBranch(tests.TestCaseWithTransport):
50
def example_branch(self, path='.', format=None):
51
tree = self.make_branch_and_tree(path, format=format)
52
self.build_tree_contents([(path + '/hello', 'foo')])
54
tree.commit(message='setup')
55
self.build_tree_contents([(path + '/goodbye', 'baz')])
57
tree.commit(message='setup')
60
def test_branch(self):
61
"""Branch from one branch to another."""
62
self.example_branch('a')
63
self.run_bzr('branch a b')
64
b = branch.Branch.open('b')
65
self.run_bzr('branch a c -r 1')
66
# previously was erroneously created by branching
67
self.assertFalse(b._transport.has('branch-name'))
68
b.controldir.open_workingtree().commit(message='foo', allow_pointless=True)
70
def test_branch_no_to_location(self):
71
"""The to_location is derived from the source branch name."""
73
a = self.example_branch('something/a').branch
74
self.run_bzr('branch something/a')
75
b = branch.Branch.open('a')
76
self.assertEqual(b.last_revision_info(), a.last_revision_info())
78
def test_into_colocated(self):
79
"""Branch from a branch into a colocated branch."""
80
self.example_branch('a')
81
out, err = self.run_bzr(
82
'init --format=development-colo file:b,branch=orig')
84
"""Created a lightweight checkout (format: development-colo)\n""",
86
self.assertEqual('', err)
87
out, err = self.run_bzr(
88
'branch a file:b,branch=thiswasa')
89
self.assertEqual('', out)
90
self.assertEqual('Branched 2 revisions.\n', err)
91
out, err = self.run_bzr('branches b')
92
self.assertEqual(" orig\n thiswasa\n", out)
93
self.assertEqual('', err)
94
out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
95
self.assertEqual('', out)
97
'brz: ERROR: Already a branch: "file:b,branch=orig".\n', err)
99
def test_from_colocated(self):
100
"""Branch from a colocated branch into a regular branch."""
101
tree = self.example_branch('a', format='development-colo')
102
tree.controldir.create_branch(name='somecolo')
103
out, err = self.run_bzr('branch %s,branch=somecolo' %
104
local_path_to_url('a'))
105
self.assertEqual('', out)
106
self.assertEqual('Branched 0 revisions.\n', err)
107
self.assertPathExists("somecolo")
109
def test_branch_broken_pack(self):
110
"""branching with a corrupted pack file."""
111
self.example_branch('a')
112
# add some corruption
113
packs_dir = 'a/.bzr/repository/packs/'
114
fname = packs_dir + os.listdir(packs_dir)[0]
115
with open(fname, 'rb+') as f:
116
# Start from the end of the file to avoid choosing a place bigger
117
# than the file itself.
118
f.seek(-5, os.SEEK_END)
120
f.seek(-5, os.SEEK_END)
121
# Make sure we inject a value different than the one we just read
126
f.write(corrupt) # make sure we corrupt something
127
self.run_bzr_error(['Corruption while decompressing repository file'],
128
'branch a b', retcode=3)
130
def test_branch_switch_no_branch(self):
131
# No branch in the current directory:
132
# => new branch will be created, but switch fails
133
self.example_branch('a')
134
self.make_repository('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())
141
def test_branch_switch_no_wt(self):
142
# No working tree in the current directory:
143
# => new branch will be created, but switch fails and the current
144
# branch is unmodified
145
self.example_branch('a')
146
self.make_branch('current')
147
self.run_bzr_error(['No WorkingTree exists for'],
148
'branch --switch ../a ../b', working_dir='current')
149
a = branch.Branch.open('a')
150
b = branch.Branch.open('b')
151
self.assertEqual(a.last_revision(), b.last_revision())
152
work = branch.Branch.open('current')
153
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
155
def test_branch_switch_no_checkout(self):
156
# Standalone branch in the current directory:
157
# => new branch will be created, but switch fails and the current
158
# branch is unmodified
159
self.example_branch('a')
160
tree = self.make_branch_and_tree('current')
161
c1 = tree.commit('some diverged change')
162
self.run_bzr_error(['Cannot switch a branch, only a checkout'],
163
'branch --switch ../a ../b', working_dir='current')
164
a = branch.Branch.open('a')
165
b = branch.Branch.open('b')
166
self.assertEqual(a.last_revision(), b.last_revision())
167
work = branch.Branch.open('current')
168
self.assertEqual(work.last_revision(), c1)
170
def test_branch_into_empty_dir(self):
171
t = self.example_branch('source')
172
self.make_controldir('target')
173
self.run_bzr("branch source target")
174
self.assertEqual(2, len(t.branch.repository.all_revision_ids()))
176
def test_branch_switch_checkout(self):
177
# Checkout in the current directory:
178
# => new branch will be created and checkout bound to the new branch
179
self.example_branch('a')
180
self.run_bzr('checkout a current')
181
out, err = self.run_bzr('branch --switch ../a ../b',
182
working_dir='current')
183
a = branch.Branch.open('a')
184
b = branch.Branch.open('b')
185
self.assertEqual(a.last_revision(), b.last_revision())
186
work = WorkingTree.open('current')
187
self.assertEndsWith(work.branch.get_bound_location(), '/b/')
188
self.assertContainsRe(err, "Switched to branch: .*/b/")
190
def test_branch_switch_lightweight_checkout(self):
191
# Lightweight checkout in the current directory:
192
# => new branch will be created and lightweight checkout pointed to
194
self.example_branch('a')
195
self.run_bzr('checkout --lightweight a current')
196
out, err = self.run_bzr('branch --switch ../a ../b',
197
working_dir='current')
198
a = branch.Branch.open('a')
199
b = branch.Branch.open('b')
200
self.assertEqual(a.last_revision(), b.last_revision())
201
work = WorkingTree.open('current')
202
self.assertEndsWith(work.branch.base, '/b/')
203
self.assertContainsRe(err, "Switched to branch: .*/b/")
205
def test_branch_only_copies_history(self):
206
# Knit branches should only push the history for the current revision.
207
format = bzrdir.BzrDirMetaFormat1()
208
format.repository_format = RepositoryFormatKnit1()
209
shared_repo = self.make_repository('repo', format=format, shared=True)
210
shared_repo.set_make_working_trees(True)
212
def make_shared_tree(path):
213
shared_repo.controldir.root_transport.mkdir(path)
214
controldir.ControlDir.create_branch_convenience('repo/' + path)
215
return WorkingTree.open('repo/' + path)
216
tree_a = make_shared_tree('a')
217
self.build_tree(['repo/a/file'])
219
tree_a.commit('commit a-1', rev_id='a-1')
220
f = open('repo/a/file', 'ab')
221
f.write('more stuff\n')
223
tree_a.commit('commit a-2', rev_id='a-2')
225
tree_b = make_shared_tree('b')
226
self.build_tree(['repo/b/file'])
228
tree_b.commit('commit b-1', rev_id='b-1')
230
self.assertTrue(shared_repo.has_revision('a-1'))
231
self.assertTrue(shared_repo.has_revision('a-2'))
232
self.assertTrue(shared_repo.has_revision('b-1'))
234
# Now that we have a repository with shared files, make sure
235
# that things aren't copied out by a 'branch'
236
self.run_bzr('branch repo/b branch-b')
237
pushed_tree = WorkingTree.open('branch-b')
238
pushed_repo = pushed_tree.branch.repository
239
self.assertFalse(pushed_repo.has_revision('a-1'))
240
self.assertFalse(pushed_repo.has_revision('a-2'))
241
self.assertTrue(pushed_repo.has_revision('b-1'))
243
def test_branch_hardlink(self):
244
self.requireFeature(HardlinkFeature)
245
source = self.make_branch_and_tree('source')
246
self.build_tree(['source/file1'])
248
source.commit('added file')
249
out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
250
source_stat = os.stat('source/file1')
251
target_stat = os.stat('target/file1')
252
self.assertEqual(source_stat, target_stat)
254
def test_branch_files_from(self):
255
source = self.make_branch_and_tree('source')
256
self.build_tree(['source/file1'])
258
source.commit('added file')
259
out, err = self.run_bzr('branch source target --files-from source')
260
self.assertPathExists('target/file1')
262
def test_branch_files_from_hardlink(self):
263
self.requireFeature(HardlinkFeature)
264
source = self.make_branch_and_tree('source')
265
self.build_tree(['source/file1'])
267
source.commit('added file')
268
source.controldir.sprout('second')
269
out, err = self.run_bzr('branch source target --files-from second'
271
source_stat = os.stat('source/file1')
272
second_stat = os.stat('second/file1')
273
target_stat = os.stat('target/file1')
274
self.assertNotEqual(source_stat, target_stat)
275
self.assertEqual(second_stat, target_stat)
277
def test_branch_standalone(self):
278
shared_repo = self.make_repository('repo', shared=True)
279
self.example_branch('source')
280
self.run_bzr('branch --standalone source repo/target')
281
b = branch.Branch.open('repo/target')
282
expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
283
self.assertEqual(strip_trailing_slash(b.repository.base),
284
strip_trailing_slash(local_path_to_url(expected_repo_path)))
286
def test_branch_no_tree(self):
287
self.example_branch('source')
288
self.run_bzr('branch --no-tree source target')
289
self.assertPathDoesNotExist('target/hello')
290
self.assertPathDoesNotExist('target/goodbye')
292
def test_branch_into_existing_dir(self):
293
self.example_branch('a')
294
# existing dir with similar files but no .brz dir
295
self.build_tree_contents([('b/',)])
296
self.build_tree_contents([('b/hello', 'bar')]) # different content
297
self.build_tree_contents([('b/goodbye', 'baz')])# same content
298
# fails without --use-existing-dir
299
out,err = self.run_bzr('branch a b', retcode=3)
300
self.assertEqual('', out)
301
self.assertEqual('brz: ERROR: Target directory "b" already exists.\n',
304
self.run_bzr('branch a b --use-existing-dir')
306
self.assertPathExists('b/hello.moved')
307
self.assertPathDoesNotExist('b/godbye.moved')
308
# we can't branch into branch
309
out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
310
self.assertEqual('', out)
311
self.assertEqual('brz: ERROR: Already a branch: "b".\n', err)
313
def test_branch_bind(self):
314
self.example_branch('a')
315
out, err = self.run_bzr('branch a b --bind')
316
self.assertEndsWith(err, "New branch bound to a\n")
317
b = branch.Branch.open('b')
318
self.assertEndsWith(b.get_bound_location(), '/a/')
320
def test_branch_with_post_branch_init_hook(self):
322
branch.Branch.hooks.install_named_hook('post_branch_init',
324
self.assertLength(0, calls)
325
self.example_branch('a')
326
self.assertLength(1, calls)
327
self.run_bzr('branch a b')
328
self.assertLength(2, calls)
330
def test_checkout_with_post_branch_init_hook(self):
332
branch.Branch.hooks.install_named_hook('post_branch_init',
334
self.assertLength(0, calls)
335
self.example_branch('a')
336
self.assertLength(1, calls)
337
self.run_bzr('checkout a b')
338
self.assertLength(2, calls)
340
def test_lightweight_checkout_with_post_branch_init_hook(self):
342
branch.Branch.hooks.install_named_hook('post_branch_init',
344
self.assertLength(0, calls)
345
self.example_branch('a')
346
self.assertLength(1, calls)
347
self.run_bzr('checkout --lightweight a b')
348
self.assertLength(2, calls)
350
def test_branch_fetches_all_tags(self):
351
builder = self.make_branch_builder('source')
352
source = fixtures.build_branch_with_non_ancestral_rev(builder)
353
source.tags.set_tag('tag-a', 'rev-2')
354
source.get_config_stack().set('branch.fetch_tags', True)
355
# Now source has a tag not in its ancestry. Make a branch from it.
356
self.run_bzr('branch source new-branch')
357
new_branch = branch.Branch.open('new-branch')
358
# The tag is present, and so is its revision.
359
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
360
new_branch.repository.get_revision('rev-2')
363
class TestBranchStacked(tests.TestCaseWithTransport):
364
"""Tests for branch --stacked"""
366
def assertRevisionInRepository(self, repo_path, revid):
367
"""Check that a revision is in a repo, disregarding stacking."""
368
repo = controldir.ControlDir.open(repo_path).open_repository()
369
self.assertTrue(repo.has_revision(revid))
371
def assertRevisionNotInRepository(self, repo_path, revid):
372
"""Check that a revision is not in a repo, disregarding stacking."""
373
repo = controldir.ControlDir.open(repo_path).open_repository()
374
self.assertFalse(repo.has_revision(revid))
376
def assertRevisionsInBranchRepository(self, revid_list, branch_path):
377
repo = branch.Branch.open(branch_path).repository
378
self.assertEqual(set(revid_list),
379
repo.has_revisions(revid_list))
381
def test_branch_stacked_branch_not_stacked(self):
382
"""Branching a stacked branch is not stacked by default"""
384
trunk_tree = self.make_branch_and_tree('target',
386
trunk_tree.commit('mainline')
387
# and a branch from it which is stacked
388
branch_tree = self.make_branch_and_tree('branch',
390
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
391
# with some work on it
392
work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
393
work_tree.commit('moar work plz')
394
work_tree.branch.push(branch_tree.branch)
395
# branching our local branch gives us a new stacked branch pointing at
397
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
398
self.assertEqual('', out)
399
self.assertEqual('Branched 2 revisions.\n',
401
# it should have preserved the branch format, and so it should be
402
# capable of supporting stacking, but not actually have a stacked_on
404
self.assertRaises(errors.NotStacked,
405
controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url)
407
def test_branch_stacked_branch_stacked(self):
408
"""Asking to stack on a stacked branch does work"""
410
trunk_tree = self.make_branch_and_tree('target',
412
trunk_revid = trunk_tree.commit('mainline')
413
# and a branch from it which is stacked
414
branch_tree = self.make_branch_and_tree('branch',
416
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
417
# with some work on it
418
work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
419
branch_revid = work_tree.commit('moar work plz')
420
work_tree.branch.push(branch_tree.branch)
421
# you can chain branches on from there
422
out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
423
self.assertEqual('', out)
424
self.assertEqual('Created new stacked branch referring to %s.\n' %
425
branch_tree.branch.base, err)
426
self.assertEqual(branch_tree.branch.base,
427
branch.Branch.open('branch2').get_stacked_on_url())
428
branch2_tree = WorkingTree.open('branch2')
429
branch2_revid = work_tree.commit('work on second stacked branch')
430
work_tree.branch.push(branch2_tree.branch)
431
self.assertRevisionInRepository('branch2', branch2_revid)
432
self.assertRevisionsInBranchRepository(
433
[trunk_revid, branch_revid, branch2_revid],
436
def test_branch_stacked(self):
438
trunk_tree = self.make_branch_and_tree('mainline',
440
original_revid = trunk_tree.commit('mainline')
441
self.assertRevisionInRepository('mainline', original_revid)
442
# and a branch from it which is stacked
443
out, err = self.run_bzr(['branch', '--stacked', 'mainline',
445
self.assertEqual('', out)
446
self.assertEqual('Created new stacked branch referring to %s.\n' %
447
trunk_tree.branch.base, err)
448
self.assertRevisionNotInRepository('newbranch', original_revid)
449
new_branch = branch.Branch.open('newbranch')
450
self.assertEqual(trunk_tree.branch.base,
451
new_branch.get_stacked_on_url())
453
def test_branch_stacked_from_smart_server(self):
454
# We can branch stacking on a smart server
455
self.transport_server = test_server.SmartTCPServer_for_testing
456
trunk = self.make_branch('mainline', format='1.9')
457
out, err = self.run_bzr(
458
['branch', '--stacked', self.get_url('mainline'), 'shallow'])
460
def test_branch_stacked_from_non_stacked_format(self):
461
"""The origin format doesn't support stacking"""
462
trunk = self.make_branch('trunk', format='pack-0.92')
463
out, err = self.run_bzr(
464
['branch', '--stacked', 'trunk', 'shallow'])
465
# We should notify the user that we upgraded their format
466
self.assertEqualDiff(
467
'Source repository format does not support stacking, using format:\n'
468
' Packs 5 (adds stacking support, requires bzr 1.6)\n'
469
'Source branch format does not support stacking, using format:\n'
471
'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
472
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
473
'Created new stacked branch referring to %s.\n' % (trunk.base,),
476
def test_branch_stacked_from_rich_root_non_stackable(self):
477
trunk = self.make_branch('trunk', format='rich-root-pack')
478
out, err = self.run_bzr(
479
['branch', '--stacked', 'trunk', 'shallow'])
480
# We should notify the user that we upgraded their format
481
self.assertEqualDiff(
482
'Source repository format does not support stacking, using format:\n'
483
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
484
'Source branch format does not support stacking, using format:\n'
486
'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
487
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
488
'Created new stacked branch referring to %s.\n' % (trunk.base,),
492
class TestSmartServerBranching(tests.TestCaseWithTransport):
494
def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
495
self.setup_smart_server_with_call_log()
496
t = self.make_branch_and_tree('from')
497
for count in range(9):
498
t.commit(message='commit %d' % count)
499
self.reset_smart_call_log()
500
out, err = self.run_bzr(['branch', self.get_url('from'),
501
self.get_url('target')])
502
# This figure represent the amount of work to perform this use case. It
503
# is entirely ok to reduce this number if a test fails due to rpc_count
504
# being too low. If rpc_count increases, more network roundtrips have
505
# become necessary for this use case. Please do not adjust this number
506
# upwards without agreement from bzr's network support maintainers.
507
self.assertLength(2, self.hpss_connections)
508
self.assertLength(33, self.hpss_calls)
509
self.expectFailure("branching to the same branch requires VFS access",
510
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
512
def test_branch_from_trivial_branch_streaming_acceptance(self):
513
self.setup_smart_server_with_call_log()
514
t = self.make_branch_and_tree('from')
515
for count in range(9):
516
t.commit(message='commit %d' % count)
517
self.reset_smart_call_log()
518
out, err = self.run_bzr(['branch', self.get_url('from'),
520
# This figure represent the amount of work to perform this use case. It
521
# is entirely ok to reduce this number if a test fails due to rpc_count
522
# being too low. If rpc_count increases, more network roundtrips have
523
# become necessary for this use case. Please do not adjust this number
524
# upwards without agreement from bzr's network support maintainers.
525
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
526
self.assertLength(10, self.hpss_calls)
527
self.assertLength(1, self.hpss_connections)
529
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
530
self.setup_smart_server_with_call_log()
531
t = self.make_branch_and_tree('trunk')
532
for count in range(8):
533
t.commit(message='commit %d' % count)
534
tree2 = t.branch.controldir.sprout('feature', stacked=True
536
local_tree = t.branch.controldir.sprout('local-working').open_workingtree()
537
local_tree.commit('feature change')
538
local_tree.branch.push(tree2.branch)
539
self.reset_smart_call_log()
540
out, err = self.run_bzr(['branch', self.get_url('feature'),
542
# This figure represent the amount of work to perform this use case. It
543
# is entirely ok to reduce this number if a test fails due to rpc_count
544
# being too low. If rpc_count increases, more network roundtrips have
545
# become necessary for this use case. Please do not adjust this number
546
# upwards without agreement from bzr's network support maintainers.
547
self.assertLength(15, self.hpss_calls)
548
self.assertLength(1, self.hpss_connections)
549
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
551
def test_branch_from_branch_with_tags(self):
552
self.setup_smart_server_with_call_log()
553
builder = self.make_branch_builder('source')
554
source = fixtures.build_branch_with_non_ancestral_rev(builder)
555
source.get_config_stack().set('branch.fetch_tags', True)
556
source.tags.set_tag('tag-a', 'rev-2')
557
source.tags.set_tag('tag-missing', 'missing-rev')
558
# Now source has a tag not in its ancestry. Make a branch from it.
559
self.reset_smart_call_log()
560
out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
561
# This figure represent the amount of work to perform this use case. It
562
# is entirely ok to reduce this number if a test fails due to rpc_count
563
# being too low. If rpc_count increases, more network roundtrips have
564
# become necessary for this use case. Please do not adjust this number
565
# upwards without agreement from bzr's network support maintainers.
566
self.assertLength(10, self.hpss_calls)
567
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
568
self.assertLength(1, self.hpss_connections)
570
def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
571
self.setup_smart_server_with_call_log()
572
t = self.make_branch_and_tree('from')
573
for count in range(9):
574
t.commit(message='commit %d' % count)
575
self.reset_smart_call_log()
576
out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
578
# XXX: the number of hpss calls for this case isn't deterministic yet,
579
# so we can't easily assert about the number of calls.
580
#self.assertLength(XXX, self.hpss_calls)
581
# We can assert that none of the calls were readv requests for rix
582
# files, though (demonstrating that at least get_parent_map calls are
583
# not using VFS RPCs).
584
readvs_of_rix_files = [
585
c for c in self.hpss_calls
586
if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
587
self.assertLength(1, self.hpss_connections)
588
self.assertLength(0, readvs_of_rix_files)
589
self.expectFailure("branching to stacked requires VFS access",
590
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
593
class TestRemoteBranch(TestCaseWithSFTPServer):
596
super(TestRemoteBranch, self).setUp()
597
tree = self.make_branch_and_tree('branch')
598
self.build_tree_contents([('branch/file', 'file content\n')])
600
tree.commit('file created')
602
def test_branch_local_remote(self):
603
self.run_bzr(['branch', 'branch', self.get_url('remote')])
604
t = self.get_transport()
605
# Ensure that no working tree what created remotely
606
self.assertFalse(t.has('remote/file'))
608
def test_branch_remote_remote(self):
609
# Light cheat: we access the branch remotely
610
self.run_bzr(['branch', self.get_url('branch'),
611
self.get_url('remote')])
612
t = self.get_transport()
613
# Ensure that no working tree what created remotely
614
self.assertFalse(t.has('remote/file'))
617
class TestDeprecatedAliases(tests.TestCaseWithTransport):
619
def test_deprecated_aliases(self):
620
"""brz branch can be called clone or get, but those names are
625
for command in ['clone', 'get']:
627
$ brz %(command)s A B
628
2>The command 'brz %(command)s' has been deprecated in brz 2.4. Please use 'brz branch' instead.
629
2>brz: ERROR: Not a branch...
633
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
635
def _checkout_and_branch(self, option=''):
636
self.script_runner.run_script(self, '''
637
$ brz checkout %(option)s repo/trunk checkout
639
$ brz branch --switch ../repo/trunk ../repo/branched
640
2>Branched 0 revisions.
641
2>Tree is up to date at revision 0.
642
2>Switched to branch:...branched...
645
bound_branch = branch.Branch.open_containing('checkout')[0]
646
master_branch = branch.Branch.open_containing('repo/branched')[0]
647
return (bound_branch, master_branch)
649
def test_branch_switch_parent_lightweight(self):
650
"""Lightweight checkout using brz branch --switch."""
651
bb, mb = self._checkout_and_branch(option='--lightweight')
652
self.assertParent('repo/trunk', bb)
653
self.assertParent('repo/trunk', mb)
655
def test_branch_switch_parent_heavyweight(self):
656
"""Heavyweight checkout using brz branch --switch."""
657
bb, mb = self._checkout_and_branch()
658
self.assertParent('repo/trunk', bb)
659
self.assertParent('repo/trunk', mb)