/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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
42
41
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
43
42
from breezy.tests.script import run_script
44
43
from breezy.urlutils import local_path_to_url, strip_trailing_slash
107
106
        self.assertEqual('Branched 0 revisions.\n', err)
108
107
        self.assertPathExists('a')
109
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')
 
119
 
110
120
    def test_branch_broken_pack(self):
111
121
        """branching with a corrupted pack file."""
112
122
        self.example_branch('a')
360
370
        self.assertEqual(rev2, new_branch.tags.lookup_tag('tag-a'))
361
371
        new_branch.repository.get_revision(rev2)
362
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')
 
420
 
363
421
 
364
422
class TestBranchStacked(tests.TestCaseWithTransport):
365
423
    """Tests for branch --stacked"""
493
551
            err)
494
552
 
495
553
 
496
 
class TestSmartServerBranching(tests.TestCaseWithTransport):
497
 
 
498
 
    def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
499
 
        self.setup_smart_server_with_call_log()
500
 
        t = self.make_branch_and_tree('from')
501
 
        for count in range(9):
502
 
            t.commit(message='commit %d' % count)
503
 
        self.reset_smart_call_log()
504
 
        out, err = self.run_bzr(['branch', self.get_url('from'),
505
 
                                 self.get_url('target')])
506
 
        # This figure represent the amount of work to perform this use case. It
507
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
508
 
        # being too low. If rpc_count increases, more network roundtrips have
509
 
        # become necessary for this use case. Please do not adjust this number
510
 
        # upwards without agreement from bzr's network support maintainers.
511
 
        self.assertLength(2, self.hpss_connections)
512
 
        self.assertLength(33, self.hpss_calls)
513
 
        self.expectFailure("branching to the same branch requires VFS access",
514
 
                           self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
515
 
 
516
 
    def test_branch_from_trivial_branch_streaming_acceptance(self):
517
 
        self.setup_smart_server_with_call_log()
518
 
        t = self.make_branch_and_tree('from')
519
 
        for count in range(9):
520
 
            t.commit(message='commit %d' % count)
521
 
        self.reset_smart_call_log()
522
 
        out, err = self.run_bzr(['branch', self.get_url('from'),
523
 
                                 'local-target'])
524
 
        # This figure represent the amount of work to perform this use case. It
525
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
526
 
        # being too low. If rpc_count increases, more network roundtrips have
527
 
        # become necessary for this use case. Please do not adjust this number
528
 
        # upwards without agreement from bzr's network support maintainers.
529
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
530
 
        self.assertLength(10, self.hpss_calls)
531
 
        self.assertLength(1, self.hpss_connections)
532
 
 
533
 
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
534
 
        self.setup_smart_server_with_call_log()
535
 
        t = self.make_branch_and_tree('trunk')
536
 
        for count in range(8):
537
 
            t.commit(message='commit %d' % count)
538
 
        tree2 = t.branch.controldir.sprout('feature', stacked=True
539
 
                                           ).open_workingtree()
540
 
        local_tree = t.branch.controldir.sprout(
541
 
            'local-working').open_workingtree()
542
 
        local_tree.commit('feature change')
543
 
        local_tree.branch.push(tree2.branch)
544
 
        self.reset_smart_call_log()
545
 
        out, err = self.run_bzr(['branch', self.get_url('feature'),
546
 
                                 'local-target'])
547
 
        # This figure represent the amount of work to perform this use case. It
548
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
549
 
        # being too low. If rpc_count increases, more network roundtrips have
550
 
        # become necessary for this use case. Please do not adjust this number
551
 
        # upwards without agreement from bzr's network support maintainers.
552
 
        self.assertLength(15, self.hpss_calls)
553
 
        self.assertLength(1, self.hpss_connections)
554
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
555
 
 
556
 
    def test_branch_from_branch_with_tags(self):
557
 
        self.setup_smart_server_with_call_log()
558
 
        builder = self.make_branch_builder('source')
559
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
560
 
            builder)
561
 
        source.get_config_stack().set('branch.fetch_tags', True)
562
 
        source.tags.set_tag('tag-a', rev2)
563
 
        source.tags.set_tag('tag-missing', b'missing-rev')
564
 
        # Now source has a tag not in its ancestry.  Make a branch from it.
565
 
        self.reset_smart_call_log()
566
 
        out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
567
 
        # This figure represent the amount of work to perform this use case. It
568
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
569
 
        # being too low. If rpc_count increases, more network roundtrips have
570
 
        # become necessary for this use case. Please do not adjust this number
571
 
        # upwards without agreement from bzr's network support maintainers.
572
 
        self.assertLength(10, self.hpss_calls)
573
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
574
 
        self.assertLength(1, self.hpss_connections)
575
 
 
576
 
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
577
 
        self.setup_smart_server_with_call_log()
578
 
        t = self.make_branch_and_tree('from')
579
 
        for count in range(9):
580
 
            t.commit(message='commit %d' % count)
581
 
        self.reset_smart_call_log()
582
 
        out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
583
 
                                 'local-target'])
584
 
        # XXX: the number of hpss calls for this case isn't deterministic yet,
585
 
        # so we can't easily assert about the number of calls.
586
 
        #self.assertLength(XXX, self.hpss_calls)
587
 
        # We can assert that none of the calls were readv requests for rix
588
 
        # files, though (demonstrating that at least get_parent_map calls are
589
 
        # not using VFS RPCs).
590
 
        readvs_of_rix_files = [
591
 
            c for c in self.hpss_calls
592
 
            if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
593
 
        self.assertLength(1, self.hpss_connections)
594
 
        self.assertLength(0, readvs_of_rix_files)
595
 
        self.expectFailure("branching to stacked requires VFS access",
596
 
                           self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
597
 
 
598
 
    def test_branch_from_branch_with_ghosts(self):
599
 
        self.setup_smart_server_with_call_log()
600
 
        t = self.make_branch_and_tree('from')
601
 
        for count in range(9):
602
 
            t.commit(message='commit %d' % count)
603
 
        t.set_parent_ids([t.last_revision(), b'ghost'])
604
 
        t.commit(message='add commit with parent')
605
 
        self.reset_smart_call_log()
606
 
        out, err = self.run_bzr(['branch', self.get_url('from'),
607
 
                                 'local-target'])
608
 
        # This figure represent the amount of work to perform this use case. It
609
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
610
 
        # being too low. If rpc_count increases, more network roundtrips have
611
 
        # become necessary for this use case. Please do not adjust this number
612
 
        # upwards without agreement from bzr's network support maintainers.
613
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
614
 
        self.assertLength(11, self.hpss_calls)
615
 
        self.assertLength(1, self.hpss_connections)
616
 
 
617
 
 
618
554
class TestRemoteBranch(TestCaseWithSFTPServer):
619
555
 
620
556
    def setUp(self):