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