~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Aaron Bentley
  • Date: 2005-07-28 13:37:16 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1020.
  • Revision ID: abentley@panoramicfeedback.com-20050728133716-be4588fe02a977f0
Fixed handling of merge factory in test suite

Show diffs side-by-side

added added

removed removed

Lines of Context:
411
411
    def change_perms_tree(self, id, tree, mode):
412
412
        os.chmod(tree.full_path(id), mode)
413
413
 
414
 
    def merge_changeset(self):
 
414
    def merge_changeset(self, merge_factory):
415
415
        all_inventory = ThreewayInventory(Inventory(self.this.inventory),
416
416
                                          Inventory(self.base.inventory), 
417
417
                                          Inventory(self.other.inventory))
418
418
        conflict_handler = changeset.ExceptionConflictHandler(self.this.dir)
419
419
        return make_merge_changeset(self.cset, all_inventory, self.this,
420
420
                                    self.base, self.other, conflict_handler,
421
 
                                    ApplyMerge3)
 
421
                                    merge_factory)
422
422
 
423
423
    def apply_inv_change(self, inventory_change, orig_inventory):
424
424
        orig_inventory_by_path = {}
486
486
        builder.change_name("2", base="name4")
487
487
        builder.add_file("3", "0", "name5", "hello3", 0755)
488
488
        builder.change_name("3", this="name6")
489
 
        cset = builder.merge_changeset()
 
489
        cset = builder.merge_changeset(ApplyMerge3)
490
490
        assert(cset.entries["2"].is_boring())
491
491
        assert(cset.entries["1"].name == "name1")
492
492
        assert(cset.entries["1"].new_name == "name2")
505
505
        builder.add_file("1", "0", "name1", "hello1", 0644)
506
506
        builder.change_name("1", other="name2", this="name3")
507
507
        self.assertRaises(changeset.RenameConflict, 
508
 
                          builder.merge_changeset)
 
508
                          builder.merge_changeset, ApplyMerge3)
509
509
        builder.cleanup()
510
510
        
511
511
    def test_file_moves(self):
522
522
        assert(Inventory(builder.this.inventory).get_parent("4") == "2")
523
523
        builder.change_parent("5", base="2")
524
524
        assert(Inventory(builder.base.inventory).get_parent("5") == "2")
525
 
        cset = builder.merge_changeset()
 
525
        cset = builder.merge_changeset(ApplyMerge3)
526
526
        for id in ("1", "2", "4", "5"):
527
527
            assert(cset.entries[id].is_boring())
528
528
        assert(cset.entries["3"].parent == "1")
537
537
        builder.add_file("4", "1", "file1", "hello1", 0644)
538
538
        builder.change_parent("4", other="2", this="3")
539
539
        self.assertRaises(changeset.MoveConflict, 
540
 
                          builder.merge_changeset)
 
540
                          builder.merge_changeset, ApplyMerge3)
541
541
        builder.cleanup()
542
542
 
543
543
    def test_contents_merge(self):
550
550
 
551
551
    def do_contents_test(self, merge_factory):
552
552
        """Test merging with specified ContentsChange factory"""
 
553
        from inspect import isclass
553
554
        builder = MergeBuilder()
554
555
        builder.add_file("1", "0", "name1", "text1", 0755)
555
556
        builder.change_contents("1", other="text4")
557
558
        builder.change_contents("2", base="text5")
558
559
        builder.add_file("3", "0", "name5", "text3", 0744)
559
560
        builder.change_contents("3", this="text6")
560
 
        cset = builder.merge_changeset()
 
561
        cset = builder.merge_changeset(merge_factory)
561
562
        assert(cset.entries["1"].contents_change is not None)
562
 
        assert(isinstance(cset.entries["1"].contents_change,
563
 
                          ApplyMerge3))
564
 
        assert(isinstance(cset.entries["2"].contents_change,
565
 
                          ApplyMerge3))
 
563
        if isclass(merge_factory):
 
564
            assert(isinstance(cset.entries["1"].contents_change,
 
565
                          merge_factory))
 
566
            assert(isinstance(cset.entries["2"].contents_change,
 
567
                          merge_factory))
566
568
        assert(cset.entries["3"].is_boring())
567
569
        builder.apply_changeset(cset)
568
570
        assert(file(builder.this.full_path("1"), "rb").read() == "text4" )
575
577
        builder = MergeBuilder()
576
578
        builder.add_file("1", "0", "name1", "text1", 0755)
577
579
        builder.change_contents("1", other="text4", this="text3")
578
 
        cset = builder.merge_changeset()
 
580
        cset = builder.merge_changeset(merge_factory)
579
581
        self.assertRaises(changeset.MergeConflict, builder.apply_changeset,
580
582
                          cset)
581
583
        builder.cleanup()
585
587
        builder.change_contents("1", other="text4", base="text3")
586
588
        builder.remove_file("1", base=True)
587
589
        self.assertRaises(changeset.NewContentsConflict,
588
 
                          builder.merge_changeset)
 
590
                          builder.merge_changeset, merge_factory)
589
591
        builder.cleanup()
590
592
 
591
593
        builder = MergeBuilder()
592
594
        builder.add_file("1", "0", "name1", "text1", 0755)
593
595
        builder.change_contents("1", other="text4", base="text3")
594
596
        builder.remove_file("1", this=True)
595
 
        self.assertRaises(changeset.MissingForMerge, builder.merge_changeset)
 
597
        self.assertRaises(changeset.MissingForMerge, builder.merge_changeset, 
 
598
                          merge_factory)
596
599
        builder.cleanup()
597
600
 
598
601
    def test_perms_merge(self):
603
606
        builder.change_perms("2", base=0655)
604
607
        builder.add_file("3", "0", "name3", "text3", 0755)
605
608
        builder.change_perms("3", this=0655)
606
 
        cset = builder.merge_changeset()
 
609
        cset = builder.merge_changeset(ApplyMerge3)
607
610
        assert(cset.entries["1"].metadata_change is not None)
608
611
        assert(isinstance(cset.entries["1"].metadata_change,
609
612
                          PermissionsMerge))
618
621
        builder = MergeBuilder()
619
622
        builder.add_file("1", "0", "name1", "text1", 0755)
620
623
        builder.change_perms("1", other=0655, base=0555)
621
 
        cset = builder.merge_changeset()
 
624
        cset = builder.merge_changeset(ApplyMerge3)
622
625
        self.assertRaises(changeset.MergePermissionConflict, 
623
626
                     builder.apply_changeset, cset)
624
627
        builder.cleanup()