15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Black-box tests for bzr branch."""
18
"""Black-box tests for brz branch."""
27
26
revision as _mod_revision,
29
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
30
from bzrlib.tests.blackbox import ExternalBase
31
from bzrlib.tests import (
29
from breezy.bzr import (
32
from breezy.bzr.knitrepo import RepositoryFormatKnit1
33
from breezy.tests import (
37
from breezy.tests.features import (
36
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
37
from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
38
from bzrlib.workingtree import WorkingTree
41
class TestBranch(ExternalBase):
43
def example_branch(self, path='.'):
44
tree = self.make_branch_and_tree(path)
45
self.build_tree_contents([(path + '/hello', 'foo')])
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', b'foo')])
47
54
tree.commit(message='setup')
48
self.build_tree_contents([(path + '/goodbye', 'baz')])
55
self.build_tree_contents([(path + '/goodbye', b'baz')])
49
56
tree.add('goodbye')
50
57
tree.commit(message='setup')
52
60
def test_branch(self):
53
61
"""Branch from one branch to another."""
57
65
self.run_bzr('branch a c -r 1')
58
66
# previously was erroneously created by branching
59
67
self.assertFalse(b._transport.has('branch-name'))
60
b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
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 standalone tree (format: development-colo)\n""",
86
self.assertEqual(b'', err)
87
out, err = self.run_bzr(
88
'branch a file:b,branch=thiswasa')
89
self.assertEqual(b'', out)
90
self.assertEqual(b'Branched 2 revisions.\n', err)
91
out, err = self.run_bzr('branches b')
92
self.assertEqual(b" orig\n thiswasa\n", out)
93
self.assertEqual(b'', err)
94
out, err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
95
self.assertEqual(b'', out)
97
b'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(b'', out)
106
self.assertEqual(b'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([b'Corruption while decompressing repository file'],
128
'branch a b', retcode=3)
62
130
def test_branch_switch_no_branch(self):
63
131
# No branch in the current directory:
64
132
# => new branch will be created, but switch fails
65
133
self.example_branch('a')
66
134
self.make_repository('current')
67
self.run_bzr_error(['No WorkingTree exists for'],
135
self.run_bzr_error([b'No WorkingTree exists for'],
68
136
'branch --switch ../a ../b', working_dir='current')
69
137
a = branch.Branch.open('a')
70
138
b = branch.Branch.open('b')
89
157
# => new branch will be created, but switch fails and the current
90
158
# branch is unmodified
91
159
self.example_branch('a')
92
self.make_branch_and_tree('current')
93
self.run_bzr_error(['Cannot switch a branch, only a checkout'],
160
tree = self.make_branch_and_tree('current')
161
c1 = tree.commit('some diverged change')
162
self.run_bzr_error([b'Cannot switch a branch, only a checkout'],
94
163
'branch --switch ../a ../b', working_dir='current')
95
164
a = branch.Branch.open('a')
96
165
b = branch.Branch.open('b')
97
166
self.assertEqual(a.last_revision(), b.last_revision())
98
167
work = branch.Branch.open('current')
99
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
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()))
101
176
def test_branch_switch_checkout(self):
102
177
# Checkout in the current directory:
103
178
# => new branch will be created and checkout bound to the new branch
104
179
self.example_branch('a')
105
180
self.run_bzr('checkout a current')
106
out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
181
out, err = self.run_bzr('branch --switch ../a ../b',
182
working_dir='current')
107
183
a = branch.Branch.open('a')
108
184
b = branch.Branch.open('b')
109
185
self.assertEqual(a.last_revision(), b.last_revision())
110
186
work = WorkingTree.open('current')
111
187
self.assertEndsWith(work.branch.get_bound_location(), '/b/')
112
self.assertContainsRe(err, "Switched to branch: .*/b/")
188
self.assertContainsRe(err, b"Switched to branch: .*/b/")
114
190
def test_branch_switch_lightweight_checkout(self):
115
191
# Lightweight checkout in the current directory:
118
194
self.example_branch('a')
119
195
self.run_bzr('checkout --lightweight a current')
120
out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
196
out, err = self.run_bzr('branch --switch ../a ../b',
197
working_dir='current')
121
198
a = branch.Branch.open('a')
122
199
b = branch.Branch.open('b')
123
200
self.assertEqual(a.last_revision(), b.last_revision())
124
201
work = WorkingTree.open('current')
125
202
self.assertEndsWith(work.branch.base, '/b/')
126
self.assertContainsRe(err, "Switched to branch: .*/b/")
203
self.assertContainsRe(err, b"Switched to branch: .*/b/")
128
205
def test_branch_only_copies_history(self):
129
206
# Knit branches should only push the history for the current revision.
133
210
shared_repo.set_make_working_trees(True)
135
212
def make_shared_tree(path):
136
shared_repo.bzrdir.root_transport.mkdir(path)
137
shared_repo.bzrdir.create_branch_convenience('repo/' + path)
213
shared_repo.controldir.root_transport.mkdir(path)
214
controldir.ControlDir.create_branch_convenience('repo/' + path)
138
215
return WorkingTree.open('repo/' + path)
139
216
tree_a = make_shared_tree('a')
140
217
self.build_tree(['repo/a/file'])
141
218
tree_a.add('file')
142
tree_a.commit('commit a-1', rev_id='a-1')
143
f = open('repo/a/file', 'ab')
144
f.write('more stuff\n')
146
tree_a.commit('commit a-2', rev_id='a-2')
219
tree_a.commit('commit a-1', rev_id=b'a-1')
220
with open('repo/a/file', 'ab') as f:
221
f.write(b'more stuff\n')
222
tree_a.commit('commit a-2', rev_id=b'a-2')
148
224
tree_b = make_shared_tree('b')
149
225
self.build_tree(['repo/b/file'])
150
226
tree_b.add('file')
151
tree_b.commit('commit b-1', rev_id='b-1')
227
tree_b.commit('commit b-1', rev_id=b'b-1')
153
self.assertTrue(shared_repo.has_revision('a-1'))
154
self.assertTrue(shared_repo.has_revision('a-2'))
155
self.assertTrue(shared_repo.has_revision('b-1'))
229
self.assertTrue(shared_repo.has_revision(b'a-1'))
230
self.assertTrue(shared_repo.has_revision(b'a-2'))
231
self.assertTrue(shared_repo.has_revision(b'b-1'))
157
233
# Now that we have a repository with shared files, make sure
158
234
# that things aren't copied out by a 'branch'
159
235
self.run_bzr('branch repo/b branch-b')
160
236
pushed_tree = WorkingTree.open('branch-b')
161
237
pushed_repo = pushed_tree.branch.repository
162
self.assertFalse(pushed_repo.has_revision('a-1'))
163
self.assertFalse(pushed_repo.has_revision('a-2'))
164
self.assertTrue(pushed_repo.has_revision('b-1'))
238
self.assertFalse(pushed_repo.has_revision(b'a-1'))
239
self.assertFalse(pushed_repo.has_revision(b'a-2'))
240
self.assertTrue(pushed_repo.has_revision(b'b-1'))
166
242
def test_branch_hardlink(self):
167
243
self.requireFeature(HardlinkFeature)
174
250
target_stat = os.stat('target/file1')
175
251
self.assertEqual(source_stat, target_stat)
253
def test_branch_files_from(self):
254
source = self.make_branch_and_tree('source')
255
self.build_tree(['source/file1'])
257
source.commit('added file')
258
out, err = self.run_bzr('branch source target --files-from source')
259
self.assertPathExists('target/file1')
261
def test_branch_files_from_hardlink(self):
262
self.requireFeature(HardlinkFeature)
263
source = self.make_branch_and_tree('source')
264
self.build_tree(['source/file1'])
266
source.commit('added file')
267
source.controldir.sprout('second')
268
out, err = self.run_bzr('branch source target --files-from second'
270
source_stat = os.stat('source/file1')
271
second_stat = os.stat('second/file1')
272
target_stat = os.stat('target/file1')
273
self.assertNotEqual(source_stat, target_stat)
274
self.assertEqual(second_stat, target_stat)
177
276
def test_branch_standalone(self):
178
277
shared_repo = self.make_repository('repo', shared=True)
179
278
self.example_branch('source')
186
285
def test_branch_no_tree(self):
187
286
self.example_branch('source')
188
287
self.run_bzr('branch --no-tree source target')
189
self.failIfExists('target/hello')
190
self.failIfExists('target/goodbye')
288
self.assertPathDoesNotExist('target/hello')
289
self.assertPathDoesNotExist('target/goodbye')
192
291
def test_branch_into_existing_dir(self):
193
292
self.example_branch('a')
194
# existing dir with similar files but no .bzr dir
293
# existing dir with similar files but no .brz dir
195
294
self.build_tree_contents([('b/',)])
196
self.build_tree_contents([('b/hello', 'bar')]) # different content
197
self.build_tree_contents([('b/goodbye', 'baz')])# same content
295
self.build_tree_contents([('b/hello', b'bar')]) # different content
296
self.build_tree_contents([('b/goodbye', b'baz')])# same content
198
297
# fails without --use-existing-dir
199
out,err = self.run_bzr('branch a b', retcode=3)
200
self.assertEqual('', out)
201
self.assertEqual('bzr: ERROR: Target directory "b" already exists.\n',
298
out, err = self.run_bzr('branch a b', retcode=3)
299
self.assertEqual(b'', out)
300
self.assertEqual(b'brz: ERROR: Target directory "b" already exists.\n',
203
302
# force operation
204
303
self.run_bzr('branch a b --use-existing-dir')
205
304
# check conflicts
206
self.failUnlessExists('b/hello.moved')
207
self.failIfExists('b/godbye.moved')
305
self.assertPathExists('b/hello.moved')
306
self.assertPathDoesNotExist('b/godbye.moved')
208
307
# we can't branch into branch
209
out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
210
self.assertEqual('', out)
211
self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
308
out, err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
309
self.assertEqual(b'', out)
310
self.assertEqual(b'brz: ERROR: Already a branch: "b".\n', err)
213
312
def test_branch_bind(self):
214
313
self.example_branch('a')
215
314
out, err = self.run_bzr('branch a b --bind')
216
self.assertEndsWith(err, "New branch bound to a\n")
315
self.assertEndsWith(err, b"New branch bound to a\n")
217
316
b = branch.Branch.open('b')
218
317
self.assertEndsWith(b.get_bound_location(), '/a/')
247
346
self.run_bzr('checkout --lightweight a b')
248
347
self.assertLength(2, calls)
251
class TestBranchStacked(ExternalBase):
349
def test_branch_fetches_all_tags(self):
350
builder = self.make_branch_builder('source')
351
source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
352
source.tags.set_tag('tag-a', rev2)
353
source.get_config_stack().set('branch.fetch_tags', True)
354
# Now source has a tag not in its ancestry. Make a branch from it.
355
self.run_bzr('branch source new-branch')
356
new_branch = branch.Branch.open('new-branch')
357
# The tag is present, and so is its revision.
358
self.assertEqual(rev2, new_branch.tags.lookup_tag('tag-a'))
359
new_branch.repository.get_revision(rev2)
362
class TestBranchStacked(tests.TestCaseWithTransport):
252
363
"""Tests for branch --stacked"""
254
365
def assertRevisionInRepository(self, repo_path, revid):
255
"""Check that a revision is in a repository, disregarding stacking."""
256
repo = bzrdir.BzrDir.open(repo_path).open_repository()
366
"""Check that a revision is in a repo, disregarding stacking."""
367
repo = controldir.ControlDir.open(repo_path).open_repository()
257
368
self.assertTrue(repo.has_revision(revid))
259
370
def assertRevisionNotInRepository(self, repo_path, revid):
260
"""Check that a revision is not in a repository, disregarding stacking."""
261
repo = bzrdir.BzrDir.open(repo_path).open_repository()
371
"""Check that a revision is not in a repo, disregarding stacking."""
372
repo = controldir.ControlDir.open(repo_path).open_repository()
262
373
self.assertFalse(repo.has_revision(revid))
264
375
def assertRevisionsInBranchRepository(self, revid_list, branch_path):
278
389
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
279
390
# with some work on it
280
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
391
work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
281
392
work_tree.commit('moar work plz')
282
393
work_tree.branch.push(branch_tree.branch)
283
394
# branching our local branch gives us a new stacked branch pointing at
285
396
out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
286
self.assertEqual('', out)
287
self.assertEqual('Branched 2 revision(s).\n',
397
self.assertEqual(b'', out)
398
self.assertEqual(b'Branched 2 revisions.\n',
289
400
# it should have preserved the branch format, and so it should be
290
401
# capable of supporting stacking, but not actually have a stacked_on
291
402
# branch configured
292
403
self.assertRaises(errors.NotStacked,
293
bzrdir.BzrDir.open('newbranch').open_branch().get_stacked_on_url)
404
controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url)
295
406
def test_branch_stacked_branch_stacked(self):
296
407
"""Asking to stack on a stacked branch does work"""
304
415
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
305
416
# with some work on it
306
work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
417
work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
307
418
branch_revid = work_tree.commit('moar work plz')
308
419
work_tree.branch.push(branch_tree.branch)
309
420
# you can chain branches on from there
310
421
out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
311
self.assertEqual('', out)
312
self.assertEqual('Created new stacked branch referring to %s.\n' %
313
branch_tree.branch.base, err)
422
self.assertEqual(b'', out)
423
self.assertEqual(b'Created new stacked branch referring to %s.\n' %
424
branch_tree.branch.base.encode('utf-8'), err)
314
425
self.assertEqual(branch_tree.branch.base,
315
426
branch.Branch.open('branch2').get_stacked_on_url())
316
427
branch2_tree = WorkingTree.open('branch2')
330
441
# and a branch from it which is stacked
331
442
out, err = self.run_bzr(['branch', '--stacked', 'mainline',
333
self.assertEqual('', out)
334
self.assertEqual('Created new stacked branch referring to %s.\n' %
335
trunk_tree.branch.base, err)
444
self.assertEqual(b'', out)
445
self.assertEqual(b'Created new stacked branch referring to %s.\n' %
446
trunk_tree.branch.base.encode('utf-8'), err)
336
447
self.assertRevisionNotInRepository('newbranch', original_revid)
337
448
new_branch = branch.Branch.open('newbranch')
338
self.assertEqual(trunk_tree.branch.base, new_branch.get_stacked_on_url())
449
self.assertEqual(trunk_tree.branch.base,
450
new_branch.get_stacked_on_url())
340
452
def test_branch_stacked_from_smart_server(self):
341
453
# We can branch stacking on a smart server
351
463
['branch', '--stacked', 'trunk', 'shallow'])
352
464
# We should notify the user that we upgraded their format
353
465
self.assertEqualDiff(
354
'Source repository format does not support stacking, using format:\n'
355
' Packs 5 (adds stacking support, requires bzr 1.6)\n'
356
'Source branch format does not support stacking, using format:\n'
358
'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
359
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
360
'Created new stacked branch referring to %s.\n' % (trunk.base,),
466
b'Source repository format does not support stacking, using format:\n'
467
b' Packs 5 (adds stacking support, requires bzr 1.6)\n'
468
b'Source branch format does not support stacking, using format:\n'
469
b' Branch format 7\n'
470
b'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
471
b'This may take some time. Upgrade the repositories to the same format for better performance.\n'
472
b'Created new stacked branch referring to %s.\n' %
473
(trunk.base.encode('utf-8'),),
363
476
def test_branch_stacked_from_rich_root_non_stackable(self):
366
479
['branch', '--stacked', 'trunk', 'shallow'])
367
480
# We should notify the user that we upgraded their format
368
481
self.assertEqualDiff(
369
'Source repository format does not support stacking, using format:\n'
370
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
371
'Source branch format does not support stacking, using format:\n'
373
'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
374
'This may take some time. Upgrade the repositories to the same format for better performance.\n'
375
'Created new stacked branch referring to %s.\n' % (trunk.base,),
482
b'Source repository format does not support stacking, using format:\n'
483
b' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
484
b'Source branch format does not support stacking, using format:\n'
485
b' Branch format 7\n'
486
b'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
487
b'This may take some time. Upgrade the repositories to the same format for better performance.\n'
488
b'Created new stacked branch referring to %s.\n' % (trunk.base.encode('utf-8'),),
379
class TestSmartServerBranching(ExternalBase):
492
class TestSmartServerBranching(tests.TestCaseWithTransport):
381
494
def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
382
495
self.setup_smart_server_with_call_log()
391
504
# being too low. If rpc_count increases, more network roundtrips have
392
505
# become necessary for this use case. Please do not adjust this number
393
506
# upwards without agreement from bzr's network support maintainers.
394
self.assertLength(38, self.hpss_calls)
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)
396
512
def test_branch_from_trivial_branch_streaming_acceptance(self):
397
513
self.setup_smart_server_with_call_log()
406
522
# being too low. If rpc_count increases, more network roundtrips have
407
523
# become necessary for this use case. Please do not adjust this number
408
524
# upwards without agreement from bzr's network support maintainers.
525
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
409
526
self.assertLength(10, self.hpss_calls)
527
self.assertLength(1, self.hpss_connections)
411
529
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
412
530
self.setup_smart_server_with_call_log()
413
531
t = self.make_branch_and_tree('trunk')
414
532
for count in range(8):
415
533
t.commit(message='commit %d' % count)
416
tree2 = t.branch.bzrdir.sprout('feature', stacked=True
534
tree2 = t.branch.controldir.sprout('feature', stacked=True
417
535
).open_workingtree()
418
local_tree = t.branch.bzrdir.sprout('local-working').open_workingtree()
536
local_tree = t.branch.controldir.sprout('local-working').open_workingtree()
419
537
local_tree.commit('feature change')
420
538
local_tree.branch.push(tree2.branch)
421
539
self.reset_smart_call_log()
427
545
# become necessary for this use case. Please do not adjust this number
428
546
# upwards without agreement from bzr's network support maintainers.
429
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, rev1, rev2 = 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', rev2)
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)
592
def test_branch_from_branch_with_ghosts(self):
593
self.setup_smart_server_with_call_log()
594
t = self.make_branch_and_tree('from')
595
for count in range(9):
596
t.commit(message='commit %d' % count)
597
t.set_parent_ids([t.last_revision(), b'ghost'])
598
t.commit(message='add commit with parent')
599
self.reset_smart_call_log()
600
out, err = self.run_bzr(['branch', self.get_url('from'),
602
# This figure represent the amount of work to perform this use case. It
603
# is entirely ok to reduce this number if a test fails due to rpc_count
604
# being too low. If rpc_count increases, more network roundtrips have
605
# become necessary for this use case. Please do not adjust this number
606
# upwards without agreement from bzr's network support maintainers.
607
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
608
self.assertLength(11, self.hpss_calls)
609
self.assertLength(1, self.hpss_connections)
432
612
class TestRemoteBranch(TestCaseWithSFTPServer):
452
632
# Ensure that no working tree what created remotely
453
633
self.assertFalse(t.has('remote/file'))
636
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
638
def _checkout_and_branch(self, option=''):
639
self.script_runner.run_script(self, '''
640
$ brz checkout %(option)s repo/trunk checkout
642
$ brz branch --switch ../repo/trunk ../repo/branched
643
2>Branched 0 revisions.
644
2>Tree is up to date at revision 0.
645
2>Switched to branch:...branched...
648
bound_branch = branch.Branch.open_containing('checkout')[0]
649
master_branch = branch.Branch.open_containing('repo/branched')[0]
650
return (bound_branch, master_branch)
652
def test_branch_switch_parent_lightweight(self):
653
"""Lightweight checkout using brz branch --switch."""
654
bb, mb = self._checkout_and_branch(option='--lightweight')
655
self.assertParent('repo/trunk', bb)
656
self.assertParent('repo/trunk', mb)
658
def test_branch_switch_parent_heavyweight(self):
659
"""Heavyweight checkout using brz branch --switch."""
660
bb, mb = self._checkout_and_branch()
661
self.assertParent('repo/trunk', bb)
662
self.assertParent('repo/trunk', mb)