~lifeless/bzr/index.range_map

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_parents.py

  • Committer: Robert Collins
  • Date: 2008-06-19 01:17:19 UTC
  • mfrom: (3218.1.277 +trunk)
  • Revision ID: robertc@robertcollins.net-20080619011719-1c4g4uxzzhdls2wf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                             _mod_revision.ensure_null(tree.last_revision()))
52
52
        else:
53
53
            self.assertEqual(expected[0], tree.last_revision())
54
 
        self.assertEqual(expected[1:],
55
 
            self.applyDeprecated(symbol_versioning.zero_eleven,
56
 
                tree.pending_merges))
57
54
 
58
55
 
59
56
class TestGetParents(TestParents):
163
160
        self.assertConsistentParents(
164
161
            [first_revision, second_revision, third_revision], t)
165
162
 
 
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)
 
174
 
 
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)
 
190
 
 
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
 
204
        # kept
 
205
        t.set_parent_ids([rev2, rev3, rev1])
 
206
        self.assertConsistentParents([rev2, rev3], t)
 
207
 
 
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),
 
221
                            (rev3, rev_tree3)])
 
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
 
225
        # kept
 
226
        t.set_parent_trees([(rev2, rev_tree2), (rev1, rev_tree1),
 
227
                            (rev3, rev_tree3)])
 
228
        self.assertConsistentParents([rev2, rev3], t)
 
229
 
166
230
 
167
231
class TestAddParent(TestParents):
168
232
 
249
313
        self.assertConsistentParents([first_revision, 'second'], tree)
250
314
 
251
315
 
252
 
class UpdateToOneParentViaDeltaTests(TestParents):
 
316
class UpdateToOneParentViaDeltaTests(TestCaseWithWorkingTree):
253
317
    """Tests for the update_basis_by_delta call.
254
318
    
255
319
    This is intuitively defined as 'apply an inventory delta to the basis and
514
578
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
515
579
            new_shape, new_revid)
516
580
 
 
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)
 
596
 
 
597
    def test_dir_to_root(self):
 
598
        # test a A->''.
 
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)
 
610
 
517
611
    def test_path_swap(self):
518
612
        # test a A->B and B->A path swap.
519
613
        old_revid = 'old-parent'