/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    HardlinkFeature,
39
39
    )
40
40
from breezy.tests.blackbox import test_switch
 
41
from breezy.tests.matchers import ContainsNoVfsCalls
41
42
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
42
43
from breezy.tests.script import run_script
43
44
from breezy.urlutils import local_path_to_url, strip_trailing_slash
48
49
 
49
50
    def example_branch(self, path='.', format=None):
50
51
        tree = self.make_branch_and_tree(path, format=format)
51
 
        self.build_tree_contents([(path + '/hello', b'foo')])
 
52
        self.build_tree_contents([(path + '/hello', 'foo')])
52
53
        tree.add('hello')
53
54
        tree.commit(message='setup')
54
 
        self.build_tree_contents([(path + '/goodbye', b'baz')])
 
55
        self.build_tree_contents([(path + '/goodbye', 'baz')])
55
56
        tree.add('goodbye')
56
57
        tree.commit(message='setup')
57
58
        return tree
80
81
        out, err = self.run_bzr(
81
82
            'init --format=development-colo file:b,branch=orig')
82
83
        self.assertEqual(
83
 
            """Created a standalone tree (format: development-colo)\n""",
 
84
            """Created a lightweight checkout (format: development-colo)\n""",
84
85
            out)
85
86
        self.assertEqual('', err)
86
87
        out, err = self.run_bzr(
90
91
        out, err = self.run_bzr('branches b')
91
92
        self.assertEqual("  orig\n  thiswasa\n", out)
92
93
        self.assertEqual('', err)
93
 
        out, err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
 
94
        out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
94
95
        self.assertEqual('', out)
95
96
        self.assertEqual(
96
97
            'brz: ERROR: Already a branch: "file:b,branch=orig".\n', err)
97
98
 
98
99
    def test_from_colocated(self):
99
100
        """Branch from a colocated branch into a regular branch."""
100
 
        os.mkdir('b')
101
 
        tree = self.example_branch('b/a', format='development-colo')
 
101
        tree = self.example_branch('a', format='development-colo')
102
102
        tree.controldir.create_branch(name='somecolo')
103
103
        out, err = self.run_bzr('branch %s,branch=somecolo' %
104
 
                                local_path_to_url('b/a'))
105
 
        self.assertEqual('', out)
106
 
        self.assertEqual('Branched 0 revisions.\n', err)
107
 
        self.assertPathExists('a')
108
 
 
109
 
    def test_from_name(self):
110
 
        """Branch from a colocated branch into a regular branch."""
111
 
        os.mkdir('b')
112
 
        tree = self.example_branch('b/a', format='development-colo')
113
 
        tree.controldir.create_branch(name='somecolo')
114
 
        out, err = self.run_bzr('branch -b somecolo %s' %
115
 
                                local_path_to_url('b/a'))
116
 
        self.assertEqual('', out)
117
 
        self.assertEqual('Branched 0 revisions.\n', err)
118
 
        self.assertPathExists('a')
 
104
            local_path_to_url('a'))
 
105
        self.assertEqual('', out)
 
106
        self.assertEqual('Branched 0 revisions.\n', err)
 
107
        self.assertPathExists("somecolo")
119
108
 
120
109
    def test_branch_broken_pack(self):
121
110
        """branching with a corrupted pack file."""
130
119
            c = f.read(1)
131
120
            f.seek(-5, os.SEEK_END)
132
121
            # Make sure we inject a value different than the one we just read
133
 
            if c == b'\xFF':
134
 
                corrupt = b'\x00'
 
122
            if c == '\xFF':
 
123
                corrupt = '\x00'
135
124
            else:
136
 
                corrupt = b'\xFF'
137
 
            f.write(corrupt)  # make sure we corrupt something
 
125
                corrupt = '\xFF'
 
126
            f.write(corrupt) # make sure we corrupt something
138
127
        self.run_bzr_error(['Corruption while decompressing repository file'],
139
 
                           'branch a b', retcode=3)
 
128
                            'branch a b', retcode=3)
140
129
 
141
130
    def test_branch_switch_no_branch(self):
142
131
        # No branch in the current directory:
144
133
        self.example_branch('a')
145
134
        self.make_repository('current')
146
135
        self.run_bzr_error(['No WorkingTree exists for'],
147
 
                           'branch --switch ../a ../b', working_dir='current')
 
136
            'branch --switch ../a ../b', working_dir='current')
148
137
        a = branch.Branch.open('a')
149
138
        b = branch.Branch.open('b')
150
139
        self.assertEqual(a.last_revision(), b.last_revision())
156
145
        self.example_branch('a')
157
146
        self.make_branch('current')
158
147
        self.run_bzr_error(['No WorkingTree exists for'],
159
 
                           'branch --switch ../a ../b', working_dir='current')
 
148
            'branch --switch ../a ../b', working_dir='current')
160
149
        a = branch.Branch.open('a')
161
150
        b = branch.Branch.open('b')
162
151
        self.assertEqual(a.last_revision(), b.last_revision())
171
160
        tree = self.make_branch_and_tree('current')
172
161
        c1 = tree.commit('some diverged change')
173
162
        self.run_bzr_error(['Cannot switch a branch, only a checkout'],
174
 
                           'branch --switch ../a ../b', working_dir='current')
 
163
            'branch --switch ../a ../b', working_dir='current')
175
164
        a = branch.Branch.open('a')
176
165
        b = branch.Branch.open('b')
177
166
        self.assertEqual(a.last_revision(), b.last_revision())
227
216
        tree_a = make_shared_tree('a')
228
217
        self.build_tree(['repo/a/file'])
229
218
        tree_a.add('file')
230
 
        tree_a.commit('commit a-1', rev_id=b'a-1')
231
 
        with open('repo/a/file', 'ab') as f:
232
 
            f.write(b'more stuff\n')
233
 
        tree_a.commit('commit a-2', rev_id=b'a-2')
 
219
        tree_a.commit('commit a-1', rev_id='a-1')
 
220
        f = open('repo/a/file', 'ab')
 
221
        f.write('more stuff\n')
 
222
        f.close()
 
223
        tree_a.commit('commit a-2', rev_id='a-2')
234
224
 
235
225
        tree_b = make_shared_tree('b')
236
226
        self.build_tree(['repo/b/file'])
237
227
        tree_b.add('file')
238
 
        tree_b.commit('commit b-1', rev_id=b'b-1')
 
228
        tree_b.commit('commit b-1', rev_id='b-1')
239
229
 
240
 
        self.assertTrue(shared_repo.has_revision(b'a-1'))
241
 
        self.assertTrue(shared_repo.has_revision(b'a-2'))
242
 
        self.assertTrue(shared_repo.has_revision(b'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'))
243
233
 
244
234
        # Now that we have a repository with shared files, make sure
245
235
        # that things aren't copied out by a 'branch'
246
236
        self.run_bzr('branch repo/b branch-b')
247
237
        pushed_tree = WorkingTree.open('branch-b')
248
238
        pushed_repo = pushed_tree.branch.repository
249
 
        self.assertFalse(pushed_repo.has_revision(b'a-1'))
250
 
        self.assertFalse(pushed_repo.has_revision(b'a-2'))
251
 
        self.assertTrue(pushed_repo.has_revision(b'b-1'))
 
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'))
252
242
 
253
243
    def test_branch_hardlink(self):
254
244
        self.requireFeature(HardlinkFeature)
291
281
        b = branch.Branch.open('repo/target')
292
282
        expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
293
283
        self.assertEqual(strip_trailing_slash(b.repository.base),
294
 
                         strip_trailing_slash(local_path_to_url(expected_repo_path)))
 
284
            strip_trailing_slash(local_path_to_url(expected_repo_path)))
295
285
 
296
286
    def test_branch_no_tree(self):
297
287
        self.example_branch('source')
303
293
        self.example_branch('a')
304
294
        # existing dir with similar files but no .brz dir
305
295
        self.build_tree_contents([('b/',)])
306
 
        self.build_tree_contents([('b/hello', b'bar')])  # different content
307
 
        self.build_tree_contents([('b/goodbye', b'baz')])  # same content
 
296
        self.build_tree_contents([('b/hello', 'bar')])  # different content
 
297
        self.build_tree_contents([('b/goodbye', 'baz')])# same content
308
298
        # fails without --use-existing-dir
309
 
        out, err = self.run_bzr('branch a b', retcode=3)
 
299
        out,err = self.run_bzr('branch a b', retcode=3)
310
300
        self.assertEqual('', out)
311
301
        self.assertEqual('brz: ERROR: Target directory "b" already exists.\n',
312
 
                         err)
 
302
            err)
313
303
        # force operation
314
304
        self.run_bzr('branch a b --use-existing-dir')
315
305
        # check conflicts
316
306
        self.assertPathExists('b/hello.moved')
317
307
        self.assertPathDoesNotExist('b/godbye.moved')
318
308
        # we can't branch into branch
319
 
        out, err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
 
309
        out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
320
310
        self.assertEqual('', out)
321
311
        self.assertEqual('brz: ERROR: Already a branch: "b".\n', err)
322
312
 
330
320
    def test_branch_with_post_branch_init_hook(self):
331
321
        calls = []
332
322
        branch.Branch.hooks.install_named_hook('post_branch_init',
333
 
                                               calls.append, None)
 
323
            calls.append, None)
334
324
        self.assertLength(0, calls)
335
325
        self.example_branch('a')
336
326
        self.assertLength(1, calls)
340
330
    def test_checkout_with_post_branch_init_hook(self):
341
331
        calls = []
342
332
        branch.Branch.hooks.install_named_hook('post_branch_init',
343
 
                                               calls.append, None)
 
333
            calls.append, None)
344
334
        self.assertLength(0, calls)
345
335
        self.example_branch('a')
346
336
        self.assertLength(1, calls)
350
340
    def test_lightweight_checkout_with_post_branch_init_hook(self):
351
341
        calls = []
352
342
        branch.Branch.hooks.install_named_hook('post_branch_init',
353
 
                                               calls.append, None)
 
343
            calls.append, None)
354
344
        self.assertLength(0, calls)
355
345
        self.example_branch('a')
356
346
        self.assertLength(1, calls)
359
349
 
360
350
    def test_branch_fetches_all_tags(self):
361
351
        builder = self.make_branch_builder('source')
362
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
363
 
            builder)
364
 
        source.tags.set_tag('tag-a', rev2)
 
352
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
353
        source.tags.set_tag('tag-a', 'rev-2')
365
354
        source.get_config_stack().set('branch.fetch_tags', True)
366
355
        # Now source has a tag not in its ancestry.  Make a branch from it.
367
356
        self.run_bzr('branch source new-branch')
368
357
        new_branch = branch.Branch.open('new-branch')
369
358
        # The tag is present, and so is its revision.
370
 
        self.assertEqual(rev2, new_branch.tags.lookup_tag('tag-a'))
371
 
        new_branch.repository.get_revision(rev2)
372
 
 
373
 
    def test_branch_with_nested_trees(self):
374
 
        orig = self.make_branch_and_tree('source', format='development-subtree')
375
 
        subtree = self.make_branch_and_tree('source/subtree')
376
 
        self.build_tree(['source/subtree/a'])
377
 
        subtree.add(['a'])
378
 
        subtree.commit('add subtree contents')
379
 
        orig.add_reference(subtree)
380
 
        orig.set_reference_info('subtree', subtree.branch.user_url)
381
 
        orig.commit('add subtree')
382
 
 
383
 
        self.run_bzr('branch source target')
384
 
 
385
 
        target = WorkingTree.open('target')
386
 
        target_subtree = WorkingTree.open('target/subtree')
387
 
        self.assertTreesEqual(orig, target)
388
 
        self.assertTreesEqual(subtree, target_subtree)
389
 
 
390
 
    def test_branch_with_nested_trees_reference_unset(self):
391
 
        orig = self.make_branch_and_tree('source', format='development-subtree')
392
 
        subtree = self.make_branch_and_tree('source/subtree')
393
 
        self.build_tree(['source/subtree/a'])
394
 
        subtree.add(['a'])
395
 
        subtree.commit('add subtree contents')
396
 
        orig.add_reference(subtree)
397
 
        orig.commit('add subtree')
398
 
 
399
 
        self.run_bzr('branch source target')
400
 
 
401
 
        target = WorkingTree.open('target')
402
 
        self.assertRaises(errors.NotBranchError, WorkingTree.open, 'target/subtree')
403
 
 
404
 
    def test_branch_with_nested_trees_no_recurse(self):
405
 
        orig = self.make_branch_and_tree('source', format='development-subtree')
406
 
        subtree = self.make_branch_and_tree('source/subtree')
407
 
        self.build_tree(['source/subtree/a'])
408
 
        subtree.add(['a'])
409
 
        subtree.commit('add subtree contents')
410
 
        orig.add_reference(subtree)
411
 
        orig.commit('add subtree')
412
 
 
413
 
        self.run_bzr('branch --no-recurse-nested source target')
414
 
 
415
 
        target = WorkingTree.open('target')
416
 
        self.addCleanup(subtree.lock_read().unlock)
417
 
        basis = subtree.basis_tree()
418
 
        self.addCleanup(basis.lock_read().unlock)
419
 
        self.assertRaises(errors.NotBranchError, WorkingTree.open, 'target/subtree')
 
359
        self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
 
360
        new_branch.repository.get_revision('rev-2')
420
361
 
421
362
 
422
363
class TestBranchStacked(tests.TestCaseWithTransport):
435
376
    def assertRevisionsInBranchRepository(self, revid_list, branch_path):
436
377
        repo = branch.Branch.open(branch_path).repository
437
378
        self.assertEqual(set(revid_list),
438
 
                         repo.has_revisions(revid_list))
 
379
            repo.has_revisions(revid_list))
439
380
 
440
381
    def test_branch_stacked_branch_not_stacked(self):
441
382
        """Branching a stacked branch is not stacked by default"""
442
383
        # We have a mainline
443
384
        trunk_tree = self.make_branch_and_tree('target',
444
 
                                               format='1.9')
 
385
            format='1.9')
445
386
        trunk_tree.commit('mainline')
446
387
        # and a branch from it which is stacked
447
388
        branch_tree = self.make_branch_and_tree('branch',
448
 
                                                format='1.9')
 
389
            format='1.9')
449
390
        branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
450
391
        # with some work on it
451
 
        work_tree = trunk_tree.branch.controldir.sprout(
452
 
            'local').open_workingtree()
 
392
        work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
453
393
        work_tree.commit('moar work plz')
454
394
        work_tree.branch.push(branch_tree.branch)
455
395
        # branching our local branch gives us a new stacked branch pointing at
457
397
        out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
458
398
        self.assertEqual('', out)
459
399
        self.assertEqual('Branched 2 revisions.\n',
460
 
                         err)
 
400
            err)
461
401
        # it should have preserved the branch format, and so it should be
462
402
        # capable of supporting stacking, but not actually have a stacked_on
463
403
        # branch configured
464
404
        self.assertRaises(errors.NotStacked,
465
 
                          controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url)
 
405
            controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url)
466
406
 
467
407
    def test_branch_stacked_branch_stacked(self):
468
408
        """Asking to stack on a stacked branch does work"""
469
409
        # We have a mainline
470
410
        trunk_tree = self.make_branch_and_tree('target',
471
 
                                               format='1.9')
 
411
            format='1.9')
472
412
        trunk_revid = trunk_tree.commit('mainline')
473
413
        # and a branch from it which is stacked
474
414
        branch_tree = self.make_branch_and_tree('branch',
475
 
                                                format='1.9')
 
415
            format='1.9')
476
416
        branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
477
417
        # with some work on it
478
 
        work_tree = trunk_tree.branch.controldir.sprout(
479
 
            'local').open_workingtree()
 
418
        work_tree = trunk_tree.branch.controldir.sprout('local').open_workingtree()
480
419
        branch_revid = work_tree.commit('moar work plz')
481
420
        work_tree.branch.push(branch_tree.branch)
482
421
        # you can chain branches on from there
483
422
        out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
484
423
        self.assertEqual('', out)
485
424
        self.assertEqual('Created new stacked branch referring to %s.\n' %
486
 
                         branch_tree.branch.base, err)
 
425
            branch_tree.branch.base, err)
487
426
        self.assertEqual(branch_tree.branch.base,
488
 
                         branch.Branch.open('branch2').get_stacked_on_url())
 
427
            branch.Branch.open('branch2').get_stacked_on_url())
489
428
        branch2_tree = WorkingTree.open('branch2')
490
429
        branch2_revid = work_tree.commit('work on second stacked branch')
491
430
        work_tree.branch.push(branch2_tree.branch)
497
436
    def test_branch_stacked(self):
498
437
        # We have a mainline
499
438
        trunk_tree = self.make_branch_and_tree('mainline',
500
 
                                               format='1.9')
 
439
            format='1.9')
501
440
        original_revid = trunk_tree.commit('mainline')
502
441
        self.assertRevisionInRepository('mainline', original_revid)
503
442
        # and a branch from it which is stacked
504
443
        out, err = self.run_bzr(['branch', '--stacked', 'mainline',
505
 
                                 'newbranch'])
 
444
            'newbranch'])
506
445
        self.assertEqual('', out)
507
446
        self.assertEqual('Created new stacked branch referring to %s.\n' %
508
 
                         trunk_tree.branch.base, err)
 
447
            trunk_tree.branch.base, err)
509
448
        self.assertRevisionNotInRepository('newbranch', original_revid)
510
449
        new_branch = branch.Branch.open('newbranch')
511
450
        self.assertEqual(trunk_tree.branch.base,
531
470
            '  Branch format 7\n'
532
471
            'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
533
472
            'This may take some time. Upgrade the repositories to the same format for better performance.\n'
534
 
            'Created new stacked branch referring to %s.\n' %
535
 
            (trunk.base,),
 
473
            'Created new stacked branch referring to %s.\n' % (trunk.base,),
536
474
            err)
537
475
 
538
476
    def test_branch_stacked_from_rich_root_non_stackable(self):
551
489
            err)
552
490
 
553
491
 
 
492
class TestSmartServerBranching(tests.TestCaseWithTransport):
 
493
 
 
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)
 
511
 
 
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'),
 
519
            'local-target'])
 
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)
 
528
 
 
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
 
535
            ).open_workingtree()
 
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'),
 
541
            'local-target'])
 
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)
 
550
 
 
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)
 
569
 
 
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'),
 
577
            'local-target'])
 
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)
 
591
 
 
592
 
554
593
class TestRemoteBranch(TestCaseWithSFTPServer):
555
594
 
556
595
    def setUp(self):
557
596
        super(TestRemoteBranch, self).setUp()
558
597
        tree = self.make_branch_and_tree('branch')
559
 
        self.build_tree_contents([('branch/file', b'file content\n')])
 
598
        self.build_tree_contents([('branch/file', 'file content\n')])
560
599
        tree.add('file')
561
600
        tree.commit('file created')
562
601