/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2007-11-06 07:30:29 UTC
  • mfrom: (2968 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2971.
  • Revision ID: bialix@ukr.net-20071106073029-h4gqz55szi1motes
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
 
261
261
    def assertDeltaApplicationResultsInExpectedBasis(self, tree, revid, delta,
262
262
        expected_inventory):
263
 
        tree.update_basis_by_delta(revid, delta)
 
263
        tree.lock_write()
 
264
        try:
 
265
            tree.update_basis_by_delta(revid, delta)
 
266
        finally:
 
267
            tree.unlock()
264
268
        # check the last revision was adjusted to rev_id
265
269
        self.assertEqual(revid, tree.last_revision())
266
270
        # check the parents are what we expect
354
358
                parents.append(extra_parent)
355
359
            tree.set_parent_ids(parents)
356
360
        self.fake_up_revision(tree, new_revid, new_shape)
 
361
        # give tree an inventory of new_shape
 
362
        tree._write_inventory(new_shape)
357
363
        self.assertDeltaApplicationResultsInExpectedBasis(tree, new_revid,
358
364
            delta, new_shape)
 
365
        # The tree should be internally consistent; while this is a moderately
 
366
        # large hammer, this is a particularly sensitive area of code, so the
 
367
        # extra assurance is well worth it.
 
368
        tree._validate()
359
369
        osutils.rmtree('tree')
360
370
 
361
371
    def test_no_parents_just_root(self):
487
497
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
488
498
            new_shape, new_revid)
489
499
 
 
500
    def test_parent_child_swap(self):
 
501
        # test a A->A/B and A/B->A path swap.
 
502
        old_revid = 'old-parent'
 
503
        basis_shape = Inventory(root_id=None)
 
504
        self.add_dir(basis_shape, old_revid, 'root-id', None, '')
 
505
        self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
 
506
        self.add_dir(basis_shape, old_revid, 'dir-id-B', 'dir-id-A', 'B')
 
507
        self.add_link(basis_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'C')
 
508
        new_revid = 'new-parent'
 
509
        new_shape = Inventory(root_id=None)
 
510
        self.add_new_root(new_shape, old_revid, new_revid)
 
511
        self.add_dir(new_shape, new_revid, 'dir-id-B', 'root-id', 'A')
 
512
        self.add_dir(new_shape, new_revid, 'dir-id-A', 'dir-id-B', 'B')
 
513
        self.add_link(new_shape, new_revid, 'link-id-C', 'dir-id-A', 'C', 'C')
 
514
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
 
515
            new_shape, new_revid)
 
516
 
490
517
    def test_path_swap(self):
491
518
        # test a A->B and B->A path swap.
492
519
        old_revid = 'old-parent'
575
602
        self.add_link(new_shape, new_revid, 'link-id-B', 'root-id', 'B', 'C')
576
603
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
577
604
            new_shape, new_revid)
 
605
 
 
606
    def test_move_moves_children_recursively(self):
 
607
        old_revid = 'old-parent'
 
608
        basis_shape = Inventory(root_id=None)
 
609
        self.add_dir(basis_shape, old_revid, 'root-id', None, '')
 
610
        self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
 
611
        self.add_dir(basis_shape, old_revid, 'dir-id-B', 'dir-id-A', 'B')
 
612
        self.add_link(basis_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'D')
 
613
        new_revid = 'new-parent'
 
614
        new_shape = Inventory(root_id=None)
 
615
        self.add_new_root(new_shape, old_revid, new_revid)
 
616
        # the moved path:
 
617
        self.add_dir(new_shape, new_revid, 'dir-id-A', 'root-id', 'B')
 
618
        # unmoved children.
 
619
        self.add_dir(new_shape, old_revid, 'dir-id-B', 'dir-id-A', 'B')
 
620
        self.add_link(new_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'D')
 
621
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
 
622
            new_shape, new_revid)