163
160
self.assertConsistentParents(
164
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)
167
231
class TestAddParent(TestParents):
514
578
self.assertTransitionFromBasisToShape(basis_shape, old_revid,
515
579
new_shape, new_revid)
581
def test_parent_deleted_child_renamed(self):
582
# test a A->None and A/B->A.
583
old_revid = 'old-parent'
584
basis_shape = Inventory(root_id=None)
585
self.add_dir(basis_shape, old_revid, 'root-id', None, '')
586
self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
587
self.add_dir(basis_shape, old_revid, 'dir-id-B', 'dir-id-A', 'B')
588
self.add_link(basis_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'C')
589
new_revid = 'new-parent'
590
new_shape = Inventory(root_id=None)
591
self.add_new_root(new_shape, old_revid, new_revid)
592
self.add_dir(new_shape, new_revid, 'dir-id-B', 'root-id', 'A')
593
self.add_link(new_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'C')
594
self.assertTransitionFromBasisToShape(basis_shape, old_revid,
595
new_shape, new_revid)
597
def test_dir_to_root(self):
599
old_revid = 'old-parent'
600
basis_shape = Inventory(root_id=None)
601
self.add_dir(basis_shape, old_revid, 'root-id', None, '')
602
self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
603
self.add_link(basis_shape, old_revid, 'link-id-B', 'dir-id-A', 'B', 'B')
604
new_revid = 'new-parent'
605
new_shape = Inventory(root_id=None)
606
self.add_dir(new_shape, new_revid, 'dir-id-A', None, '')
607
self.add_link(new_shape, old_revid, 'link-id-B', 'dir-id-A', 'B', 'B')
608
self.assertTransitionFromBasisToShape(basis_shape, old_revid,
609
new_shape, new_revid)
517
611
def test_path_swap(self):
518
612
# test a A->B and B->A path swap.
519
613
old_revid = 'old-parent'