~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Abbreviate pack_stat struct format to '>6L'

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.tests import TestCaseWithTransport
30
30
from bzrlib.tests import (
31
31
    fixtures,
32
 
    HardlinkFeature,
33
32
    script,
34
33
    test_server,
35
34
    )
 
35
from bzrlib.tests.features import (
 
36
    HardlinkFeature,
 
37
    )
36
38
from bzrlib.tests.blackbox import test_switch
37
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
38
40
from bzrlib.tests.script import run_script
61
63
        self.assertFalse(b._transport.has('branch-name'))
62
64
        b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
63
65
 
 
66
    def test_branch_broken_pack(self):
 
67
        """branching with a corrupted pack file."""
 
68
        self.example_branch('a')
 
69
        # add some corruption
 
70
        packs_dir = 'a/.bzr/repository/packs/'
 
71
        fname = packs_dir + os.listdir(packs_dir)[0]
 
72
        with open(fname, 'rb+') as f:
 
73
            # Start from the end of the file to avoid choosing a place bigger
 
74
            # than the file itself.
 
75
            f.seek(-5, os.SEEK_END)
 
76
            c = f.read(1)
 
77
            f.seek(-5, os.SEEK_END)
 
78
            # Make sure we inject a value different than the one we just read
 
79
            if c == '\xFF':
 
80
                corrupt = '\x00'
 
81
            else:
 
82
                corrupt = '\xFF'
 
83
            f.write(corrupt) # make sure we corrupt something
 
84
        self.run_bzr_error(['Corruption while decompressing repository file'], 
 
85
                            'branch a b', retcode=3)
 
86
 
64
87
    def test_branch_switch_no_branch(self):
65
88
        # No branch in the current directory:
66
89
        #  => new branch will be created, but switch fails
276
299
        builder = self.make_branch_builder('source')
277
300
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
278
301
        source.tags.set_tag('tag-a', 'rev-2')
 
302
        source.get_config().set_user_option('branch.fetch_tags', 'True')
279
303
        # Now source has a tag not in its ancestry.  Make a branch from it.
280
304
        self.run_bzr('branch source new-branch')
281
305
        new_branch = branch.Branch.open('new-branch')
320
344
        # mainline.
321
345
        out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
322
346
        self.assertEqual('', out)
323
 
        self.assertEqual('Branched 2 revision(s).\n',
 
347
        self.assertEqual('Branched 2 revisions.\n',
324
348
            err)
325
349
        # it should have preserved the branch format, and so it should be
326
350
        # capable of supporting stacking, but not actually have a stacked_on
427
451
        # being too low. If rpc_count increases, more network roundtrips have
428
452
        # become necessary for this use case. Please do not adjust this number
429
453
        # upwards without agreement from bzr's network support maintainers.
430
 
        self.assertLength(36, self.hpss_calls)
 
454
        self.assertLength(39, self.hpss_calls)
431
455
 
432
456
    def test_branch_from_trivial_branch_streaming_acceptance(self):
433
457
        self.setup_smart_server_with_call_log()
442
466
        # being too low. If rpc_count increases, more network roundtrips have
443
467
        # become necessary for this use case. Please do not adjust this number
444
468
        # upwards without agreement from bzr's network support maintainers.
445
 
        self.assertLength(9, self.hpss_calls)
 
469
        self.assertLength(10, self.hpss_calls)
446
470
 
447
471
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
448
472
        self.setup_smart_server_with_call_log()
462
486
        # being too low. If rpc_count increases, more network roundtrips have
463
487
        # become necessary for this use case. Please do not adjust this number
464
488
        # upwards without agreement from bzr's network support maintainers.
465
 
        self.assertLength(14, self.hpss_calls)
 
489
        self.assertLength(15, self.hpss_calls)
466
490
 
467
491
    def test_branch_from_branch_with_tags(self):
468
492
        self.setup_smart_server_with_call_log()
469
493
        builder = self.make_branch_builder('source')
470
494
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
495
        source.get_config().set_user_option('branch.fetch_tags', 'True')
471
496
        source.tags.set_tag('tag-a', 'rev-2')
472
497
        source.tags.set_tag('tag-missing', 'missing-rev')
473
498
        # Now source has a tag not in its ancestry.  Make a branch from it.
478
503
        # being too low. If rpc_count increases, more network roundtrips have
479
504
        # become necessary for this use case. Please do not adjust this number
480
505
        # upwards without agreement from bzr's network support maintainers.
481
 
        self.assertLength(9, self.hpss_calls)
 
506
        self.assertLength(10, self.hpss_calls)
482
507
 
483
508
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
484
509
        self.setup_smart_server_with_call_log()
546
571
                $ bzr checkout %(option)s repo/trunk checkout
547
572
                $ cd checkout
548
573
                $ bzr branch --switch ../repo/trunk ../repo/branched
549
 
                2>Branched 0 revision(s).
 
574
                2>Branched 0 revisions.
550
575
                2>Tree is up to date at revision 0.
551
576
                2>Switched to branch:...branched...
552
577
                $ cd ..