19
from bzrlib.tests import TestCaseWithTransport
20
from bzrlib.workingtree import WorkingTree
21
from bzrlib.branch import Branch
19
from breezy.tests import TestCaseWithTransport
24
21
class TestAncestry(TestCaseWithTransport):
26
23
def _build_branches(self):
27
24
a_wt = self.make_branch_and_tree('A')
28
self.build_tree_contents([('A/foo', '1111\n')])
25
self.build_tree_contents([('A/foo', b'1111\n')])
30
a_wt.commit('added foo',rev_id='A1')
32
b_wt = a_wt.bzrdir.sprout('B').open_workingtree()
33
self.build_tree_contents([('B/foo', '1111\n22\n')])
34
b_wt.commit('modified B/foo',rev_id='B1')
36
self.build_tree_contents([('A/foo', '000\n1111\n')])
37
a_wt.commit('modified A/foo',rev_id='A2')
27
a_wt.commit('added foo', rev_id=b'A1')
29
b_wt = a_wt.controldir.sprout('B').open_workingtree()
30
self.build_tree_contents([('B/foo', b'1111\n22\n')])
31
b_wt.commit('modified B/foo', rev_id=b'B1')
33
self.build_tree_contents([('A/foo', b'000\n1111\n')])
34
a_wt.commit('modified A/foo', rev_id=b'A2')
39
36
a_wt.merge_from_branch(b_wt.branch, b_wt.last_revision(),
40
37
b_wt.branch.get_rev_id(1))
41
a_wt.commit('merged B into A',rev_id='A3')
38
a_wt.commit('merged B into A', rev_id=b'A3')
44
41
def _check_ancestry(self, location='', result=None):
72
69
self.make_repository('repo', shared=True)
74
a_tree.bzrdir.sprout('repo/A')
71
a_tree.controldir.sprout('repo/A')
75
72
self._check_ancestry('repo/A')
77
74
def test_ancestry_with_checkout(self):
79
76
checkout of a repository branch."""
80
77
a_tree = self._build_branches()[0]
81
78
self.make_repository('repo', shared=True)
82
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
79
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
83
80
repo_branch.create_checkout('A-checkout')
84
81
self._check_ancestry('A-checkout')
88
85
lightweight checkout of a repository branch."""
89
86
a_tree = self._build_branches()[0]
90
87
self.make_repository('repo', shared=True)
91
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
88
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
92
89
repo_branch.create_checkout('A-checkout', lightweight=True)
93
90
self._check_ancestry('A-checkout')
97
94
checkout of a repository branch with a shortened revision history."""
98
95
a_tree = self._build_branches()[0]
99
96
self.make_repository('repo', shared=True)
100
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
97
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
101
98
repo_branch.create_checkout('A-checkout',
102
99
revision_id=repo_branch.get_rev_id(2))
103
100
self._check_ancestry('A-checkout', "A1\nA2\n")
107
104
checkout of a repository branch with a shortened revision history."""
108
105
a_tree = self._build_branches()[0]
109
106
self.make_repository('repo', shared=True)
110
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
107
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
111
108
repo_branch.create_checkout('A-checkout',
112
109
revision_id=repo_branch.get_rev_id(2),
113
110
lightweight=True)