32
45
# now give it a real parent, and then set it to no parents again.
33
46
t.commit('first post')
34
47
t.set_parent_trees([])
35
self.assertEqual([], t.get_parent_ids())
36
self.assertEqual(None, t.last_revision())
37
self.assertEqual([], t.pending_merges())
48
self.assertConsistentParents([], t)
39
50
def test_set_one_ghost_parent(self):
40
51
t = self.make_branch_and_tree('.')
41
52
t.set_parent_trees([('missing-revision-id', None)])
42
self.assertEqual(['missing-revision-id'], t.get_parent_ids())
43
self.assertEqual('missing-revision-id', t.last_revision())
44
self.assertEqual([], t.pending_merges())
53
self.assertConsistentParents(['missing-revision-id'], t)
46
55
def test_set_two_parents_one_ghost(self):
47
56
t = self.make_branch_and_tree('.')
70
76
t.set_parent_trees([(first_revision, rev_tree1),
71
77
(second_revision, rev_tree2),
72
78
(third_revision, rev_tree3)])
73
self.assertEqual([first_revision, second_revision, third_revision],
75
self.assertEqual(first_revision, t.last_revision())
76
self.assertEqual([second_revision, third_revision], t.pending_merges())
79
self.assertConsistentParents(
80
[first_revision, second_revision, third_revision], t)
82
def test_set_no_parents_ids(self):
83
t = self.make_branch_and_tree('.')
85
self.assertEqual([], t.get_parent_ids())
86
# now give it a real parent, and then set it to no parents again.
87
t.commit('first post')
89
self.assertConsistentParents([], t)
91
def test_set_one_ghost_parent_ids(self):
92
t = self.make_branch_and_tree('.')
93
t.set_parent_ids(['missing-revision-id'])
94
self.assertConsistentParents(['missing-revision-id'], t)
96
def test_set_two_parents_one_ghost_ids(self):
97
t = self.make_branch_and_tree('.')
98
revision_in_repo = t.commit('first post')
99
# remove the tree's history
100
uncommit(t.branch, tree=t)
101
rev_tree = t.branch.repository.revision_tree(revision_in_repo)
102
t.set_parent_ids([revision_in_repo, 'another-missing'])
103
self.assertConsistentParents([revision_in_repo, 'another-missing'], t)
105
def test_set_three_parents_ids(self):
106
t = self.make_branch_and_tree('.')
107
first_revision = t.commit('first post')
108
uncommit(t.branch, tree=t)
109
second_revision = t.commit('second post')
110
uncommit(t.branch, tree=t)
111
third_revision = t.commit('third post')
112
uncommit(t.branch, tree=t)
113
rev_tree1 = t.branch.repository.revision_tree(first_revision)
114
rev_tree2 = t.branch.repository.revision_tree(second_revision)
115
rev_tree3 = t.branch.repository.revision_tree(third_revision)
116
t.set_parent_ids([first_revision, second_revision, third_revision])
117
self.assertConsistentParents(
118
[first_revision, second_revision, third_revision], t)
121
class TestAddParentId(TestParents):
123
def test_add_first_parent_id(self):
124
"""Test adding the first parent id"""
125
tree = self.make_branch_and_tree('.')
126
first_revision = tree.commit('first post')
127
uncommit(tree.branch, tree=tree)
128
tree.add_parent_tree_id(first_revision)
129
self.assertConsistentParents([first_revision], tree)
131
def test_add_first_parent_id_ghost(self):
132
"""Test adding the first parent id - as a ghost"""
133
tree = self.make_branch_and_tree('.')
134
tree.add_parent_tree_id('first-revision')
135
self.assertConsistentParents(['first-revision'], tree)
137
def test_add_second_parent_id(self):
138
"""Test adding the second parent id"""
139
tree = self.make_branch_and_tree('.')
140
first_revision = tree.commit('first post')
141
uncommit(tree.branch, tree=tree)
142
second_revision = tree.commit('second post')
143
tree.add_parent_tree_id(first_revision)
144
self.assertConsistentParents([second_revision, first_revision], tree)
146
def test_add_second_parent_id_ghost(self):
147
"""Test adding the second parent id - as a ghost"""
148
tree = self.make_branch_and_tree('.')
149
first_revision = tree.commit('first post')
150
tree.add_parent_tree_id('second')
151
self.assertConsistentParents([first_revision, 'second'], tree)