1
# Copyright (C) 2006-2012 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,
30
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
31
from bzrlib.tests import (
35
from bzrlib.tests.features import (
38
from bzrlib.tests.blackbox import test_switch
39
from bzrlib.tests.matchers import ContainsNoVfsCalls
40
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
41
from bzrlib.tests.script import run_script
42
from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
43
from bzrlib.workingtree import WorkingTree
46
class TestBranch(tests.TestCaseWithTransport):
48
def example_branch(self, path='.', format=None):
49
tree = self.make_branch_and_tree(path, format=format)
50
self.build_tree_contents([(path + '/hello', 'foo')])
52
tree.commit(message='setup')
53
self.build_tree_contents([(path + '/goodbye', 'baz')])
55
tree.commit(message='setup')
58
def test_branch(self):
59
"""Branch from one branch to another."""
60
self.example_branch('a')
61
self.run_bzr('branch a b')
62
b = branch.Branch.open('b')
63
self.run_bzr('branch a c -r 1')
64
# previously was erroneously created by branching
65
self.assertFalse(b._transport.has('branch-name'))
66
b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
68
def test_into_colocated(self):
69
"""Branch from a branch into a colocated branch."""
70
self.example_branch('a')
71
out, err = self.run_bzr(
72
'init --format=development-colo file:b,branch=orig')
74
"""Created a lightweight checkout (format: development-colo)\n""",
76
self.assertEqual('', err)
77
out, err = self.run_bzr(
78
'branch a file:b,branch=thiswasa')
79
self.assertEqual('', out)
80
self.assertEqual('Branched 2 revisions.\n', err)
81
out, err = self.run_bzr('branches b')
82
self.assertEqual(" orig\n thiswasa\n", out)
83
self.assertEqual('', err)
84
out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
85
self.assertEqual('', out)
87
'bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
89
def test_from_colocated(self):
90
"""Branch from a colocated branch into a regular branch."""
91
tree = self.example_branch('a', format='development-colo')
92
tree.bzrdir.create_branch(name='somecolo')
93
out, err = self.run_bzr('branch %s,branch=somecolo' %
94
local_path_to_url('a'))
95
self.assertEqual('', out)
96
self.assertEqual('Branched 0 revisions.\n', err)
97
self.assertPathExists("somecolo")
99
def test_branch_broken_pack(self):
100
"""branching with a corrupted pack file."""
101
self.example_branch('a')
102
# add some corruption
103
packs_dir = 'a/.bzr/repository/packs/'
104
fname = packs_dir + os.listdir(packs_dir)[0]
105
with open(fname, 'rb+') as f:
106
# Start from the end of the file to avoid choosing a place bigger
107
# than the file itself.
108
f.seek(-5, os.SEEK_END)
110
f.seek(-5, os.SEEK_END)
111
# Make sure we inject a value different than the one we just read
116
f.write(corrupt) # make sure we corrupt something
117
self.run_bzr_error(['Corruption while decompressing repository file'],
118
'branch a b', retcode=3)
120
def test_branch_switch_no_branch(self):
121
# No branch in the current directory:
122
# => new branch will be created, but switch fails
123
self.example_branch('a')
124
self.make_repository('current')
125
self.run_bzr_error(['No WorkingTree exists for'],
126
'branch --switch ../a ../b', working_dir='current')
127
a = branch.Branch.open('a')
128
b = branch.Branch.open('b')
129
self.assertEqual(a.last_revision(), b.last_revision())
131
def test_branch_switch_no_wt(self):
132
# No working tree in the current directory:
133
# => new branch will be created, but switch fails and the current
134
# branch is unmodified
135
self.example_branch('a')
136
self.make_branch('current')
137
self.run_bzr_error(['No WorkingTree exists for'],
138
'branch --switch ../a ../b', working_dir='current')
139
a = branch.Branch.open('a')
140
b = branch.Branch.open('b')
141
self.assertEqual(a.last_revision(), b.last_revision())
142
work = branch.Branch.open('current')
143
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
145
def test_branch_switch_no_checkout(self):
146
# Standalone branch in the current directory:
147
# => new branch will be created, but switch fails and the current
148
# branch is unmodified
149
self.example_branch('a')
150
self.make_branch_and_tree('current')
151
self.run_bzr_error(['Cannot switch a branch, only a checkout'],
152
'branch --switch ../a ../b', working_dir='current')
153
a = branch.Branch.open('a')
154
b = branch.Branch.open('b')
155
self.assertEqual(a.last_revision(), b.last_revision())
156
work = branch.Branch.open('current')
157
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
159
def test_branch_switch_checkout(self):
160
# Checkout in the current directory:
161
# => new branch will be created and checkout bound to the new branch
162
self.example_branch('a')
163
self.run_bzr('checkout a current')
164
out, err = self.run_bzr('branch --switch ../a ../b',
165
working_dir='current')
166
a = branch.Branch.open('a')
167
b = branch.Branch.open('b')
168
self.assertEqual(a.last_revision(), b.last_revision())
169
work = WorkingTree.open('current')
170
self.assertEndsWith(work.branch.get_bound_location(), '/b/')
171
self.assertContainsRe(err, "Switched to branch: .*/b/")
173
def test_branch_switch_lightweight_checkout(self):
174
# Lightweight checkout in the current directory:
175
# => new branch will be created and lightweight checkout pointed to
177
self.example_branch('a')
178
self.run_bzr('checkout --lightweight a current')
179
out, err = self.run_bzr('branch --switch ../a ../b',
180
working_dir='current')
181
a = branch.Branch.open('a')
182
b = branch.Branch.open('b')
183
self.assertEqual(a.last_revision(), b.last_revision())
184
work = WorkingTree.open('current')
185
self.assertEndsWith(work.branch.base, '/b/')
186
self.assertContainsRe(err, "Switched to branch: .*/b/")
188
def test_branch_only_copies_history(self):
189
# Knit branches should only push the history for the current revision.
190
format = bzrdir.BzrDirMetaFormat1()
191
format.repository_format = RepositoryFormatKnit1()
192
shared_repo = self.make_repository('repo', format=format, shared=True)
193
shared_repo.set_make_working_trees(True)
195
def make_shared_tree(path):
196
shared_repo.bzrdir.root_transport.mkdir(path)
197
controldir.ControlDir.create_branch_convenience('repo/' + path)
198
return WorkingTree.open('repo/' + path)
199
tree_a = make_shared_tree('a')
200
self.build_tree(['repo/a/file'])
202
tree_a.commit('commit a-1', rev_id='a-1')
203
f = open('repo/a/file', 'ab')
204
f.write('more stuff\n')
206
tree_a.commit('commit a-2', rev_id='a-2')
208
tree_b = make_shared_tree('b')
209
self.build_tree(['repo/b/file'])
211
tree_b.commit('commit b-1', rev_id='b-1')
213
self.assertTrue(shared_repo.has_revision('a-1'))
214
self.assertTrue(shared_repo.has_revision('a-2'))
215
self.assertTrue(shared_repo.has_revision('b-1'))
217
# Now that we have a repository with shared files, make sure
218
# that things aren't copied out by a 'branch'
219
self.run_bzr('branch repo/b branch-b')
220
pushed_tree = WorkingTree.open('branch-b')
221
pushed_repo = pushed_tree.branch.repository
222
self.assertFalse(pushed_repo.has_revision('a-1'))
223
self.assertFalse(pushed_repo.has_revision('a-2'))
224
self.assertTrue(pushed_repo.has_revision('b-1'))
226
def test_branch_hardlink(self):
227
self.requireFeature(HardlinkFeature)
228
source = self.make_branch_and_tree('source')
229
self.build_tree(['source/file1'])
231
source.commit('added file')
232
out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
233
source_stat = os.stat('source/file1')
234
target_stat = os.stat('target/file1')
235
self.assertEqual(source_stat, target_stat)
237
def test_branch_files_from(self):
238
source = self.make_branch_and_tree('source')
239
self.build_tree(['source/file1'])
241
source.commit('added file')
242
out, err = self.run_bzr('branch source target --files-from source')
243
self.assertPathExists('target/file1')
245
def test_branch_files_from_hardlink(self):
246
self.requireFeature(HardlinkFeature)
247
source = self.make_branch_and_tree('source')
248
self.build_tree(['source/file1'])
250
source.commit('added file')
251
source.bzrdir.sprout('second')
252
out, err = self.run_bzr('branch source target --files-from second'
254
source_stat = os.stat('source/file1')
255
second_stat = os.stat('second/file1')
256
target_stat = os.stat('target/file1')
257
self.assertNotEqual(source_stat, target_stat)
258
self.assertEqual(second_stat, target_stat)
260
def test_branch_standalone(self):
261
shared_repo = self.make_repository('repo', shared=True)
262
self.example_branch('source')
263
self.run_bzr('branch --standalone source repo/target')
264
b = branch.Branch.open('repo/target')
265
expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
266
self.assertEqual(strip_trailing_slash(b.repository.base),
267
strip_trailing_slash(local_path_to_url(expected_repo_path)))
269
def test_branch_no_tree(self):
270
self.example_branch('source')
271
self.run_bzr('branch --no-tree source target')
272
self.assertPathDoesNotExist('target/hello')
273
self.assertPathDoesNotExist('target/goodbye')
275
def test_branch_into_existing_dir(self):
276
self.example_branch('a')
277
# existing dir with similar files but no .bzr dir
278
self.build_tree_contents([('b/',)])
279
self.build_tree_contents([('b/hello', 'bar')]) # different content
280
self.build_tree_contents([('b/goodbye', 'baz')])# same content
281
# fails without --use-existing-dir
282
out,err = self.run_bzr('branch a b', retcode=3)
283
self.assertEqual('', out)
284
self.assertEqual('bzr: ERROR: Target directory "b" already exists.\n',
287
self.run_bzr('branch a b --use-existing-dir')
289
self.assertPathExists('b/hello.moved')
290
self.assertPathDoesNotExist('b/godbye.moved')
291
# we can't branch into branch
292
out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
293
self.assertEqual('', out)
294
self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
296
def test_branch_bind(self):
297
self.example_branch('a')
298
out, err = self.run_bzr('branch a b --bind')
299
self.assertEndsWith(err, "New branch bound to a\n")
300
b = branch.Branch.open('b')
301
self.assertEndsWith(b.get_bound_location(), '/a/')
303
def test_branch_with_post_branch_init_hook(self):
305
branch.Branch.hooks.install_named_hook('post_branch_init',
307
self.assertLength(0, calls)
308
self.example_branch('a')
309
self.assertLength(1, calls)
310
self.run_bzr('branch a b')
311
self.assertLength(2, calls)
313
def test_checkout_with_post_branch_init_hook(self):
315
branch.Branch.hooks.install_named_hook('post_branch_init',
317
self.assertLength(0, calls)
318
self.example_branch('a')
319
self.assertLength(1, calls)
320
self.run_bzr('checkout a b')
321
self.assertLength(2, calls)
323
def test_lightweight_checkout_with_post_branch_init_hook(self):
325
branch.Branch.hooks.install_named_hook('post_branch_init',
327
self.assertLength(0, calls)
328
self.example_branch('a')
329
self.assertLength(1, calls)
330
self.run_bzr('checkout --lightweight a b')
331
self.assertLength(2, calls)
333
def test_branch_fetches_all_tags(self):
334
builder = self.make_branch_builder('source')
335
source = fixtures.build_branch_with_non_ancestral_rev(builder)
336
source.tags.set_tag('tag-a', 'rev-2')
339
source.get_config_stack().set('branch.fetch_tags', True)
342
# Now source has a tag not in its ancestry. Make a branch from it.
343
self.run_bzr('branch source new-branch')
344
new_branch = branch.Branch.open('new-branch')
345
# The tag is present, and so is its revision.
346
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
347
new_branch.repository.get_revision('rev-2')
350
class TestBranchStacked(tests.TestCaseWithTransport):
351
"""Tests for branch --stacked"""
353
def assertRevisionInRepository(self, repo_path, revid):
354
"""Check that a revision is in a repo, disregarding stacking."""
355
repo = bzrdir.BzrDir.open(repo_path).open_repository()
356
self.assertTrue(repo.has_revision(revid))
358
def assertRevisionNotInRepository(self, repo_path, revid):
359
"""Check that a revision is not in a repo, disregarding stacking."""
360
repo = bzrdir.BzrDir.open(repo_path).open_repository()
361
self.assertFalse(repo.has_revision(revid))
363
def assertRevisionsInBranchRepository(self, revid_list, branch_path):
364
repo = branch.Branch.open(branch_path).repository
365
self.assertEqual(set(revid_list),
366
repo.has_revisions(revid_list))
368
def test_branch_stacked_branch_not_stacked(self):
369
"""Branching a stacked branch is not stacked by default"""
371
trunk_tree = self.make_branch_and_tree('target',
373
trunk_tree.commit('mainline')
374
# and a branch from it which is stacked
375
branch_tree = self.make_branch_and_tree('branch',
377
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
378
# with some work on it
379
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
380
work_tree.commit('moar work plz')
381
work_tree.branch.push(branch_tree.branch)
382
# branching our local branch gives us a new stacked branch pointing at
384
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
385
self.assertEqual('', out)
386
self.assertEqual('Branched 2 revisions.\n',
388
# it should have preserved the branch format, and so it should be
389
# capable of supporting stacking, but not actually have a stacked_on
391
self.assertRaises(errors.NotStacked,
392
bzrdir.BzrDir.open('newbranch').open_branch().get_stacked_on_url)
394
def test_branch_stacked_branch_stacked(self):
395
"""Asking to stack on a stacked branch does work"""
397
trunk_tree = self.make_branch_and_tree('target',
399
trunk_revid = trunk_tree.commit('mainline')
400
# and a branch from it which is stacked
401
branch_tree = self.make_branch_and_tree('branch',
403
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
404
# with some work on it
405
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
406
branch_revid = work_tree.commit('moar work plz')
407
work_tree.branch.push(branch_tree.branch)
408
# you can chain branches on from there
409
out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
410
self.assertEqual('', out)
411
self.assertEqual('Created new stacked branch referring to %s.\n' %
412
branch_tree.branch.base, err)
413
self.assertEqual(branch_tree.branch.base,
414
branch.Branch.open('branch2').get_stacked_on_url())
415
branch2_tree = WorkingTree.open('branch2')
416
branch2_revid = work_tree.commit('work on second stacked branch')
417
work_tree.branch.push(branch2_tree.branch)
418
self.assertRevisionInRepository('branch2', branch2_revid)
419
self.assertRevisionsInBranchRepository(
420
[trunk_revid, branch_revid, branch2_revid],
423
def test_branch_stacked(self):
425
trunk_tree = self.make_branch_and_tree('mainline',
427
original_revid = trunk_tree.commit('mainline')
428
self.assertRevisionInRepository('mainline', original_revid)
429
# and a branch from it which is stacked
430
out, err = self.run_bzr(['branch', '--stacked', 'mainline',
432
self.assertEqual('', out)
433
self.assertEqual('Created new stacked branch referring to %s.\n' %
434
trunk_tree.branch.base, err)
435
self.assertRevisionNotInRepository('newbranch', original_revid)
436
new_branch = branch.Branch.open('newbranch')
437
self.assertEqual(trunk_tree.branch.base,
438
new_branch.get_stacked_on_url())
440
def test_branch_stacked_from_smart_server(self):
441
# We can branch stacking on a smart server
442
self.transport_server = test_server.SmartTCPServer_for_testing
443
trunk = self.make_branch('mainline', format='1.9')
444
out, err = self.run_bzr(
445
['branch', '--stacked', self.get_url('mainline'), 'shallow'])
447
def test_branch_stacked_from_non_stacked_format(self):
448
"""The origin format doesn't support stacking"""
449
trunk = self.make_branch('trunk', format='pack-0.92')
450
out, err = self.run_bzr(
451
['branch', '--stacked', 'trunk', 'shallow'])
452
# We should notify the user that we upgraded their format
453
self.assertEqualDiff(
454
'Source repository format does not support stacking, using format:\n'
455
' Packs 5 (adds stacking support, requires bzr 1.6)\n'
456
'Source branch format does not support stacking, using format:\n'
458
'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
459
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
460
'Created new stacked branch referring to %s.\n' % (trunk.base,),
463
def test_branch_stacked_from_rich_root_non_stackable(self):
464
trunk = self.make_branch('trunk', format='rich-root-pack')
465
out, err = self.run_bzr(
466
['branch', '--stacked', 'trunk', 'shallow'])
467
# We should notify the user that we upgraded their format
468
self.assertEqualDiff(
469
'Source repository format does not support stacking, using format:\n'
470
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
471
'Source branch format does not support stacking, using format:\n'
473
'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
474
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
475
'Created new stacked branch referring to %s.\n' % (trunk.base,),
479
class TestSmartServerBranching(tests.TestCaseWithTransport):
481
def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
482
self.setup_smart_server_with_call_log()
483
t = self.make_branch_and_tree('from')
484
for count in range(9):
485
t.commit(message='commit %d' % count)
486
self.reset_smart_call_log()
487
out, err = self.run_bzr(['branch', self.get_url('from'),
488
self.get_url('target')])
489
# This figure represent the amount of work to perform this use case. It
490
# is entirely ok to reduce this number if a test fails due to rpc_count
491
# being too low. If rpc_count increases, more network roundtrips have
492
# become necessary for this use case. Please do not adjust this number
493
# upwards without agreement from bzr's network support maintainers.
494
self.assertLength(2, self.hpss_connections)
495
self.assertLength(33, self.hpss_calls)
496
self.expectFailure("branching to the same branch requires VFS access",
497
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
499
def test_branch_from_trivial_branch_streaming_acceptance(self):
500
self.setup_smart_server_with_call_log()
501
t = self.make_branch_and_tree('from')
502
for count in range(9):
503
t.commit(message='commit %d' % count)
504
self.reset_smart_call_log()
505
out, err = self.run_bzr(['branch', self.get_url('from'),
507
# This figure represent the amount of work to perform this use case. It
508
# is entirely ok to reduce this number if a test fails due to rpc_count
509
# being too low. If rpc_count increases, more network roundtrips have
510
# become necessary for this use case. Please do not adjust this number
511
# upwards without agreement from bzr's network support maintainers.
512
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
513
self.assertLength(10, self.hpss_calls)
514
self.assertLength(1, self.hpss_connections)
516
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
517
self.setup_smart_server_with_call_log()
518
t = self.make_branch_and_tree('trunk')
519
for count in range(8):
520
t.commit(message='commit %d' % count)
521
tree2 = t.branch.bzrdir.sprout('feature', stacked=True
523
local_tree = t.branch.bzrdir.sprout('local-working').open_workingtree()
524
local_tree.commit('feature change')
525
local_tree.branch.push(tree2.branch)
526
self.reset_smart_call_log()
527
out, err = self.run_bzr(['branch', self.get_url('feature'),
529
# This figure represent the amount of work to perform this use case. It
530
# is entirely ok to reduce this number if a test fails due to rpc_count
531
# being too low. If rpc_count increases, more network roundtrips have
532
# become necessary for this use case. Please do not adjust this number
533
# upwards without agreement from bzr's network support maintainers.
534
self.assertLength(15, self.hpss_calls)
535
self.assertLength(1, self.hpss_connections)
536
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
538
def test_branch_from_branch_with_tags(self):
539
self.setup_smart_server_with_call_log()
540
builder = self.make_branch_builder('source')
541
source = fixtures.build_branch_with_non_ancestral_rev(builder)
542
source.get_config_stack().set('branch.fetch_tags', True)
543
source.tags.set_tag('tag-a', 'rev-2')
544
source.tags.set_tag('tag-missing', 'missing-rev')
545
# Now source has a tag not in its ancestry. Make a branch from it.
546
self.reset_smart_call_log()
547
out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
548
# This figure represent the amount of work to perform this use case. It
549
# is entirely ok to reduce this number if a test fails due to rpc_count
550
# being too low. If rpc_count increases, more network roundtrips have
551
# become necessary for this use case. Please do not adjust this number
552
# upwards without agreement from bzr's network support maintainers.
553
self.assertLength(10, self.hpss_calls)
554
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
555
self.assertLength(1, self.hpss_connections)
557
def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
558
self.setup_smart_server_with_call_log()
559
t = self.make_branch_and_tree('from')
560
for count in range(9):
561
t.commit(message='commit %d' % count)
562
self.reset_smart_call_log()
563
out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
565
# XXX: the number of hpss calls for this case isn't deterministic yet,
566
# so we can't easily assert about the number of calls.
567
#self.assertLength(XXX, self.hpss_calls)
568
# We can assert that none of the calls were readv requests for rix
569
# files, though (demonstrating that at least get_parent_map calls are
570
# not using VFS RPCs).
571
readvs_of_rix_files = [
572
c for c in self.hpss_calls
573
if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
574
self.assertLength(1, self.hpss_connections)
575
self.assertLength(0, readvs_of_rix_files)
576
self.expectFailure("branching to stacked requires VFS access",
577
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
580
class TestRemoteBranch(TestCaseWithSFTPServer):
583
super(TestRemoteBranch, self).setUp()
584
tree = self.make_branch_and_tree('branch')
585
self.build_tree_contents([('branch/file', 'file content\n')])
587
tree.commit('file created')
589
def test_branch_local_remote(self):
590
self.run_bzr(['branch', 'branch', self.get_url('remote')])
591
t = self.get_transport()
592
# Ensure that no working tree what created remotely
593
self.assertFalse(t.has('remote/file'))
595
def test_branch_remote_remote(self):
596
# Light cheat: we access the branch remotely
597
self.run_bzr(['branch', self.get_url('branch'),
598
self.get_url('remote')])
599
t = self.get_transport()
600
# Ensure that no working tree what created remotely
601
self.assertFalse(t.has('remote/file'))
604
class TestDeprecatedAliases(tests.TestCaseWithTransport):
606
def test_deprecated_aliases(self):
607
"""bzr branch can be called clone or get, but those names are
612
for command in ['clone', 'get']:
614
$ bzr %(command)s A B
615
2>The command 'bzr %(command)s' has been deprecated in bzr 2.4. Please use 'bzr branch' instead.
616
2>bzr: ERROR: Not a branch...
620
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
622
def _checkout_and_branch(self, option=''):
623
self.script_runner.run_script(self, '''
624
$ bzr checkout %(option)s repo/trunk checkout
626
$ bzr branch --switch ../repo/trunk ../repo/branched
627
2>Branched 0 revisions.
628
2>Tree is up to date at revision 0.
629
2>Switched to branch:...branched...
632
bound_branch = branch.Branch.open_containing('checkout')[0]
633
master_branch = branch.Branch.open_containing('repo/branched')[0]
634
return (bound_branch, master_branch)
636
def test_branch_switch_parent_lightweight(self):
637
"""Lightweight checkout using bzr branch --switch."""
638
bb, mb = self._checkout_and_branch(option='--lightweight')
639
self.assertParent('repo/trunk', bb)
640
self.assertParent('repo/trunk', mb)
642
def test_branch_switch_parent_heavyweight(self):
643
"""Heavyweight checkout using bzr branch --switch."""
644
bb, mb = self._checkout_and_branch()
645
self.assertParent('repo/trunk', bb)
646
self.assertParent('repo/trunk', mb)