/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 bzrlib/tests/blackbox/test_branch.py

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

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,
 
33
    test_server,
 
34
    )
 
35
from bzrlib.tests.features import (
32
36
    HardlinkFeature,
33
 
    script,
34
 
    test_server,
35
37
    )
36
38
from bzrlib.tests.blackbox import test_switch
37
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
42
44
 
43
45
class TestBranch(TestCaseWithTransport):
44
46
 
45
 
    def example_branch(self, path='.'):
46
 
        tree = self.make_branch_and_tree(path)
 
47
    def example_branch(self, path='.', format=None):
 
48
        tree = self.make_branch_and_tree(path, format=format)
47
49
        self.build_tree_contents([(path + '/hello', 'foo')])
48
50
        tree.add('hello')
49
51
        tree.commit(message='setup')
50
52
        self.build_tree_contents([(path + '/goodbye', 'baz')])
51
53
        tree.add('goodbye')
52
54
        tree.commit(message='setup')
 
55
        return tree
53
56
 
54
57
    def test_branch(self):
55
58
        """Branch from one branch to another."""
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 lightweight checkout (format: development-colo)\n""",
 
74
            out)
 
75
        self.assertEqual('', err)
 
76
        out, err = self.run_bzr(
 
77
            'branch 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
        out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
 
84
        self.assertEqual('', out)
 
85
        self.assertEqual('bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
 
86
 
 
87
    def test_from_colocated(self):
 
88
        """Branch from a colocated branch into a regular branch."""
 
89
        tree = self.example_branch('a', format='development-colo')
 
90
        tree.bzrdir.create_branch(name='somecolo')
 
91
        out, err = self.run_bzr('branch %s,branch=somecolo' %
 
92
            local_path_to_url('a'))
 
93
        self.assertEqual('', out)
 
94
        self.assertEqual('Branched 0 revisions.\n', err)
 
95
        self.assertPathExists("somecolo")
 
96
 
64
97
    def test_branch_broken_pack(self):
65
98
        """branching with a corrupted pack file."""
66
99
        self.example_branch('a')
157
190
 
158
191
        def make_shared_tree(path):
159
192
            shared_repo.bzrdir.root_transport.mkdir(path)
160
 
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
 
193
            controldir.ControlDir.create_branch_convenience('repo/' + path)
161
194
            return WorkingTree.open('repo/' + path)
162
195
        tree_a = make_shared_tree('a')
163
196
        self.build_tree(['repo/a/file'])
342
375
        # mainline.
343
376
        out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
344
377
        self.assertEqual('', out)
345
 
        self.assertEqual('Branched 2 revision(s).\n',
 
378
        self.assertEqual('Branched 2 revisions.\n',
346
379
            err)
347
380
        # it should have preserved the branch format, and so it should be
348
381
        # capable of supporting stacking, but not actually have a stacked_on
449
482
        # being too low. If rpc_count increases, more network roundtrips have
450
483
        # become necessary for this use case. Please do not adjust this number
451
484
        # upwards without agreement from bzr's network support maintainers.
452
 
        self.assertLength(37, self.hpss_calls)
 
485
        self.assertLength(40, self.hpss_calls)
453
486
 
454
487
    def test_branch_from_trivial_branch_streaming_acceptance(self):
455
488
        self.setup_smart_server_with_call_log()
569
602
                $ bzr checkout %(option)s repo/trunk checkout
570
603
                $ cd checkout
571
604
                $ bzr branch --switch ../repo/trunk ../repo/branched
572
 
                2>Branched 0 revision(s).
 
605
                2>Branched 0 revisions.
573
606
                2>Tree is up to date at revision 0.
574
607
                2>Switched to branch:...branched...
575
608
                $ cd ..