~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    branch,
24
24
    bzrdir,
 
25
    controldir,
25
26
    errors,
26
27
    revision as _mod_revision,
27
28
    )
29
30
from bzrlib.tests import TestCaseWithTransport
30
31
from bzrlib.tests import (
31
32
    fixtures,
32
 
    HardlinkFeature,
33
33
    script,
34
34
    test_server,
35
35
    )
 
36
from bzrlib.tests.features import (
 
37
    HardlinkFeature,
 
38
    )
36
39
from bzrlib.tests.blackbox import test_switch
37
40
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
38
41
from bzrlib.tests.script import run_script
61
64
        self.assertFalse(b._transport.has('branch-name'))
62
65
        b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
63
66
 
 
67
    def test_into_colocated(self):
 
68
        """Branch from a branch into a colocated branch."""
 
69
        self.example_branch('a')
 
70
        out, err = self.run_bzr(
 
71
            'init --format=development-colo file:b,branch=orig')
 
72
        self.assertEqual(
 
73
            """Created a standalone tree (format: development-colo)\n""",
 
74
            out)
 
75
        self.assertEqual('', err)
 
76
        out, err = self.run_bzr(
 
77
            'branch --use-existing-dir a file:b,branch=thiswasa')
 
78
        self.assertEqual('', out)
 
79
        self.assertEqual('Branched 2 revisions.\n', err)
 
80
        out, err = self.run_bzr('branches b')
 
81
        self.assertEqual(" orig\n thiswasa\n", out)
 
82
        self.assertEqual('', err)
 
83
 
64
84
    def test_branch_broken_pack(self):
65
85
        """branching with a corrupted pack file."""
66
86
        self.example_branch('a')
67
 
        #now add some random corruption
68
 
        fname = 'a/.bzr/repository/packs/' + os.listdir('a/.bzr/repository/packs')[0]
 
87
        # add some corruption
 
88
        packs_dir = 'a/.bzr/repository/packs/'
 
89
        fname = packs_dir + os.listdir(packs_dir)[0]
69
90
        with open(fname, 'rb+') as f:
70
 
            f.seek(750)
71
 
            f.write("\xff")
 
91
            # Start from the end of the file to avoid choosing a place bigger
 
92
            # than the file itself.
 
93
            f.seek(-5, os.SEEK_END)
 
94
            c = f.read(1)
 
95
            f.seek(-5, os.SEEK_END)
 
96
            # Make sure we inject a value different than the one we just read
 
97
            if c == '\xFF':
 
98
                corrupt = '\x00'
 
99
            else:
 
100
                corrupt = '\xFF'
 
101
            f.write(corrupt) # make sure we corrupt something
72
102
        self.run_bzr_error(['Corruption while decompressing repository file'], 
73
103
                            'branch a b', retcode=3)
74
104
 
147
177
 
148
178
        def make_shared_tree(path):
149
179
            shared_repo.bzrdir.root_transport.mkdir(path)
150
 
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
 
180
            controldir.ControlDir.create_branch_convenience('repo/' + path)
151
181
            return WorkingTree.open('repo/' + path)
152
182
        tree_a = make_shared_tree('a')
153
183
        self.build_tree(['repo/a/file'])
287
317
        builder = self.make_branch_builder('source')
288
318
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
289
319
        source.tags.set_tag('tag-a', 'rev-2')
 
320
        source.get_config().set_user_option('branch.fetch_tags', 'True')
290
321
        # Now source has a tag not in its ancestry.  Make a branch from it.
291
322
        self.run_bzr('branch source new-branch')
292
323
        new_branch = branch.Branch.open('new-branch')
331
362
        # mainline.
332
363
        out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
333
364
        self.assertEqual('', out)
334
 
        self.assertEqual('Branched 2 revision(s).\n',
 
365
        self.assertEqual('Branched 2 revisions.\n',
335
366
            err)
336
367
        # it should have preserved the branch format, and so it should be
337
368
        # capable of supporting stacking, but not actually have a stacked_on
438
469
        # being too low. If rpc_count increases, more network roundtrips have
439
470
        # become necessary for this use case. Please do not adjust this number
440
471
        # upwards without agreement from bzr's network support maintainers.
441
 
        self.assertLength(36, self.hpss_calls)
 
472
        self.assertLength(39, self.hpss_calls)
442
473
 
443
474
    def test_branch_from_trivial_branch_streaming_acceptance(self):
444
475
        self.setup_smart_server_with_call_log()
453
484
        # being too low. If rpc_count increases, more network roundtrips have
454
485
        # become necessary for this use case. Please do not adjust this number
455
486
        # upwards without agreement from bzr's network support maintainers.
456
 
        self.assertLength(9, self.hpss_calls)
 
487
        self.assertLength(10, self.hpss_calls)
457
488
 
458
489
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
459
490
        self.setup_smart_server_with_call_log()
473
504
        # being too low. If rpc_count increases, more network roundtrips have
474
505
        # become necessary for this use case. Please do not adjust this number
475
506
        # upwards without agreement from bzr's network support maintainers.
476
 
        self.assertLength(14, self.hpss_calls)
 
507
        self.assertLength(15, self.hpss_calls)
477
508
 
478
509
    def test_branch_from_branch_with_tags(self):
479
510
        self.setup_smart_server_with_call_log()
480
511
        builder = self.make_branch_builder('source')
481
512
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
513
        source.get_config().set_user_option('branch.fetch_tags', 'True')
482
514
        source.tags.set_tag('tag-a', 'rev-2')
483
515
        source.tags.set_tag('tag-missing', 'missing-rev')
484
516
        # Now source has a tag not in its ancestry.  Make a branch from it.
489
521
        # being too low. If rpc_count increases, more network roundtrips have
490
522
        # become necessary for this use case. Please do not adjust this number
491
523
        # upwards without agreement from bzr's network support maintainers.
492
 
        self.assertLength(9, self.hpss_calls)
 
524
        self.assertLength(10, self.hpss_calls)
493
525
 
494
526
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
495
527
        self.setup_smart_server_with_call_log()
557
589
                $ bzr checkout %(option)s repo/trunk checkout
558
590
                $ cd checkout
559
591
                $ bzr branch --switch ../repo/trunk ../repo/branched
560
 
                2>Branched 0 revision(s).
 
592
                2>Branched 0 revisions.
561
593
                2>Tree is up to date at revision 0.
562
594
                2>Switched to branch:...branched...
563
595
                $ cd ..