/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/branch_implementations/test_create_clone.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-04 13:27:50 UTC
  • mfrom: (4075 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4076.
  • Revision ID: jelmer@samba.org-20090304132750-2mdmad8r8agxc0hn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for branch.create_clone behaviour."""
18
18
 
 
19
from bzrlib.branch import Branch
 
20
from bzrlib import errors
 
21
from bzrlib import remote
 
22
from bzrlib import tests
19
23
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
20
24
 
21
25
 
54
58
            stacked_on=trunk.base)
55
59
        self.assertEqual(revid, result.last_revision())
56
60
        self.assertEqual(trunk.base, result.get_stacked_on_url())
 
61
 
 
62
    def test_create_clone_of_multiple_roots(self):
 
63
        try:
 
64
            builder = self.make_branch_builder('local')
 
65
        except (errors.TransportNotPossible, errors.UninitializableFormat):
 
66
            raise tests.TestNotApplicable('format not directly constructable')
 
67
        builder.start_series()
 
68
        builder.build_snapshot('rev1', None, [
 
69
            ('add', ('', 'root-id', 'directory', ''))])
 
70
        builder.build_snapshot('rev2', ['rev1'], [])
 
71
        builder.build_snapshot('other', None, [
 
72
            ('add', ('', 'root-id', 'directory', ''))])
 
73
        builder.build_snapshot('rev3', ['rev2', 'other'], [])
 
74
        builder.finish_series()
 
75
        local = builder.get_branch()
 
76
        local.bzrdir.clone(self.get_url('remote'), revision_id='rev3')
 
77
 
 
78
    def assertBranchHookBranchIsStacked(self, pre_change_params):
 
79
        # Just calling will either succeed or fail.
 
80
        pre_change_params.branch.get_stacked_on_url()
 
81
        self.hook_calls.append(pre_change_params)
 
82
 
 
83
    def test_create_clone_on_transport_stacked_hooks_get_stacked_branch(self):
 
84
        tree = self.make_branch_and_tree('source')
 
85
        tree.commit('a commit')
 
86
        trunk = tree.branch.create_clone_on_transport(
 
87
            self.get_transport('trunk'))
 
88
        revid = tree.commit('a second commit')
 
89
        source = tree.branch
 
90
        target_transport = self.get_transport('target')
 
91
        self.hook_calls = []
 
92
        Branch.hooks.install_named_hook("pre_change_branch_tip",
 
93
            self.assertBranchHookBranchIsStacked, None)
 
94
        result = tree.branch.create_clone_on_transport(target_transport,
 
95
            stacked_on=trunk.base)
 
96
        self.assertEqual(revid, result.last_revision())
 
97
        self.assertEqual(trunk.base, result.get_stacked_on_url())
 
98
        # Smart servers invoke hooks on both sides
 
99
        if isinstance(result, remote.RemoteBranch):
 
100
            expected_calls = 2
 
101
        else:
 
102
            expected_calls = 1
 
103
        self.assertEqual(expected_calls, len(self.hook_calls))