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
22
class TestAncestry(TestCaseWithTransport):
26
24
def _build_branches(self):
27
25
a_wt = self.make_branch_and_tree('A')
28
self.build_tree_contents([('A/foo', '1111\n')])
26
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')
28
a_wt.commit('added foo', rev_id=b'A1')
30
b_wt = a_wt.controldir.sprout('B').open_workingtree()
31
self.build_tree_contents([('B/foo', b'1111\n22\n')])
32
b_wt.commit('modified B/foo', rev_id=b'B1')
34
self.build_tree_contents([('A/foo', b'000\n1111\n')])
35
a_wt.commit('modified A/foo', rev_id=b'A2')
39
37
a_wt.merge_from_branch(b_wt.branch, b_wt.last_revision(),
40
b_wt.branch.get_rev_id(1))
41
a_wt.commit('merged B into A',rev_id='A3')
38
b_wt.branch.get_rev_id(1))
39
a_wt.commit('merged B into A', rev_id=b'A3')
44
42
def _check_ancestry(self, location='', result=None):
72
70
self.make_repository('repo', shared=True)
74
a_tree.bzrdir.sprout('repo/A')
72
a_tree.controldir.sprout('repo/A')
75
73
self._check_ancestry('repo/A')
77
75
def test_ancestry_with_checkout(self):
79
77
checkout of a repository branch."""
80
78
a_tree = self._build_branches()[0]
81
79
self.make_repository('repo', shared=True)
82
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
80
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
83
81
repo_branch.create_checkout('A-checkout')
84
82
self._check_ancestry('A-checkout')
88
86
lightweight checkout of a repository branch."""
89
87
a_tree = self._build_branches()[0]
90
88
self.make_repository('repo', shared=True)
91
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
89
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
92
90
repo_branch.create_checkout('A-checkout', lightweight=True)
93
91
self._check_ancestry('A-checkout')
97
95
checkout of a repository branch with a shortened revision history."""
98
96
a_tree = self._build_branches()[0]
99
97
self.make_repository('repo', shared=True)
100
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
98
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
101
99
repo_branch.create_checkout('A-checkout',
102
100
revision_id=repo_branch.get_rev_id(2))
103
101
self._check_ancestry('A-checkout', "A1\nA2\n")
107
105
checkout of a repository branch with a shortened revision history."""
108
106
a_tree = self._build_branches()[0]
109
107
self.make_repository('repo', shared=True)
110
repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
108
repo_branch = a_tree.controldir.sprout('repo/A').open_branch()
111
109
repo_branch.create_checkout('A-checkout',
112
110
revision_id=repo_branch.get_rev_id(2),
113
111
lightweight=True)