160
160
self.assertConsistentParents(
161
161
[first_revision, second_revision, third_revision], t)
163
def test_set_duplicate_parent_ids(self):
164
t = self.make_branch_and_tree('.')
165
rev1 = t.commit('first post')
166
uncommit(t.branch, tree=t)
167
rev2 = t.commit('second post')
168
uncommit(t.branch, tree=t)
169
rev3 = t.commit('third post')
170
uncommit(t.branch, tree=t)
171
t.set_parent_ids([rev1, rev2, rev2, rev3])
172
# We strip the duplicate, but preserve the ordering
173
self.assertConsistentParents([rev1, rev2, rev3], t)
175
def test_set_duplicate_parent_trees(self):
176
t = self.make_branch_and_tree('.')
177
rev1 = t.commit('first post')
178
uncommit(t.branch, tree=t)
179
rev2 = t.commit('second post')
180
uncommit(t.branch, tree=t)
181
rev3 = t.commit('third post')
182
uncommit(t.branch, tree=t)
183
rev_tree1 = t.branch.repository.revision_tree(rev1)
184
rev_tree2 = t.branch.repository.revision_tree(rev2)
185
rev_tree3 = t.branch.repository.revision_tree(rev3)
186
t.set_parent_trees([(rev1, rev_tree1), (rev2, rev_tree2),
187
(rev2, rev_tree2), (rev3, rev_tree3)])
188
# We strip the duplicate, but preserve the ordering
189
self.assertConsistentParents([rev1, rev2, rev3], t)
191
def test_set_parent_ids_in_ancestry(self):
192
t = self.make_branch_and_tree('.')
193
rev1 = t.commit('first post')
194
rev2 = t.commit('second post')
195
rev3 = t.commit('third post')
196
# Reset the tree, back to rev1
197
t.set_parent_ids([rev1])
198
t.branch.set_last_revision_info(1, rev1)
199
self.assertConsistentParents([rev1], t)
200
t.set_parent_ids([rev1, rev2, rev3])
201
# rev2 is in the ancestry of rev3, so it will be filtered out
202
self.assertConsistentParents([rev1, rev3], t)
203
# Order should be preserved, and the first revision should always be
205
t.set_parent_ids([rev2, rev3, rev1])
206
self.assertConsistentParents([rev2, rev3], t)
208
def test_set_parent_trees_in_ancestry(self):
209
t = self.make_branch_and_tree('.')
210
rev1 = t.commit('first post')
211
rev2 = t.commit('second post')
212
rev3 = t.commit('third post')
213
# Reset the tree, back to rev1
214
t.set_parent_ids([rev1])
215
t.branch.set_last_revision_info(1, rev1)
216
self.assertConsistentParents([rev1], t)
217
rev_tree1 = t.branch.repository.revision_tree(rev1)
218
rev_tree2 = t.branch.repository.revision_tree(rev2)
219
rev_tree3 = t.branch.repository.revision_tree(rev3)
220
t.set_parent_trees([(rev1, rev_tree1), (rev2, rev_tree2),
222
# rev2 is in the ancestry of rev3, so it will be filtered out
223
self.assertConsistentParents([rev1, rev3], t)
224
# Order should be preserved, and the first revision should always be
226
t.set_parent_trees([(rev2, rev_tree2), (rev1, rev_tree1),
228
self.assertConsistentParents([rev2, rev3], t)
164
231
class TestAddParent(TestParents):