~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_merge_core.py

[merge] much integrated work from robert and john

Show diffs side-by-side

added added

removed removed

Lines of Context:
537
537
        self.build_tree(("original/", "original/file1", "original/file2"))
538
538
        branch = Branch.initialize("original")
539
539
        smart_add_branch(branch, ["original"], True, add_reporter_null)
540
 
        branch.commit("start branch.", verbose=False)
 
540
        branch.working_tree().commit("start branch.", verbose=False)
541
541
        # Mary branches it.
542
542
        self.build_tree(("mary/",))
543
543
        copy_branch(branch, "mary")
545
545
        file = open("original/file1", "wt")
546
546
        file.write("John\n")
547
547
        file.close()
548
 
        branch.commit("change file1")
 
548
        branch.working_tree().commit("change file1")
549
549
        # Mary does too
550
550
        mary_branch = Branch.open("mary")
551
551
        file = open("mary/file2", "wt")
552
552
        file.write("Mary\n")
553
553
        file.close()
554
 
        mary_branch.commit("change file2")
 
554
        mary_branch.working_tree().commit("change file2")
555
555
        # john should be able to merge with no conflicts.
556
556
        merge_type = ApplyMerge3
557
557
        base = [None, None]
569
569
        a = Branch.initialize('a')
570
570
        file('a/file', 'wb').write('contents\n')
571
571
        a.add('file')
572
 
        a.commit('base revision', allow_pointless=False)
 
572
        a.working_tree().commit('base revision', allow_pointless=False)
573
573
        b = copy_branch(a, 'b')
574
574
        file('a/file', 'wb').write('other contents\n')
575
 
        a.commit('other revision', allow_pointless=False)
 
575
        a.working_tree().commit('other revision', allow_pointless=False)
576
576
        file('b/file', 'wb').write('this contents contents\n')
577
 
        b.commit('this revision', allow_pointless=False)
 
577
        b.working_tree().commit('this revision', allow_pointless=False)
578
578
        self.assertEqual(merge(['a', -1], [None, None], this_dir='b'), 1)
579
579
        self.assert_(os.path.lexists('b/file.THIS'))
580
580
        self.assert_(os.path.lexists('b/file.BASE'))
599
599
        a = Branch.initialize('a')
600
600
        file('a/a_file', 'wb').write('contents\n')
601
601
        a.add('a_file')
602
 
        a.commit('a_revision', allow_pointless=False)
 
602
        a.working_tree().commit('a_revision', allow_pointless=False)
603
603
        os.mkdir('b')
604
604
        b = Branch.initialize('b')
605
605
        file('b/b_file', 'wb').write('contents\n')
606
606
        b.add('b_file')
607
 
        b.commit('b_revision', allow_pointless=False)
 
607
        b.working_tree().commit('b_revision', allow_pointless=False)
608
608
        merge(['b', -1], ['b', 0], this_dir='a')
609
609
        self.assert_(os.path.lexists('a/b_file'))
610
 
        self.assertEqual(a.pending_merges(), [b.last_revision()]) 
 
610
        self.assertEqual(a.working_tree().pending_merges(),
 
611
                         [b.last_revision()]) 
611
612
 
612
613
    def test_merge_unrelated_conflicting(self):
613
614
        """Sucessfully merges unrelated branches with common names"""
615
616
        a = Branch.initialize('a')
616
617
        file('a/file', 'wb').write('contents\n')
617
618
        a.add('file')
618
 
        a.commit('a_revision', allow_pointless=False)
 
619
        a.working_tree().commit('a_revision', allow_pointless=False)
619
620
        os.mkdir('b')
620
621
        b = Branch.initialize('b')
621
622
        file('b/file', 'wb').write('contents\n')
622
623
        b.add('file')
623
 
        b.commit('b_revision', allow_pointless=False)
 
624
        b.working_tree().commit('b_revision', allow_pointless=False)
624
625
        merge(['b', -1], ['b', 0], this_dir='a')
625
626
        self.assert_(os.path.lexists('a/file'))
626
627
        self.assert_(os.path.lexists('a/file.moved'))
627
 
        self.assertEqual(a.pending_merges(), [b.last_revision()]) 
 
628
        self.assertEqual(a.working_tree().pending_merges(), [b.last_revision()])
628
629
 
629
630
    def test_merge_metadata_vs_deletion(self):
630
631
        """Conflict deletion vs metadata change"""
632
633
        a = Branch.initialize('a')
633
634
        file('a/file', 'wb').write('contents\n')
634
635
        a.add('file')
635
 
        a.commit('r0')
 
636
        a_wt = a.working_tree()
 
637
        a_wt.commit('r0')
636
638
        copy_branch(a, 'b')
637
639
        b = Branch.open('b')
 
640
        b_wt = b.working_tree()
638
641
        os.chmod('b/file', 0755)
639
642
        os.remove('a/file')
640
 
        a.commit('removed a')
 
643
        a_wt.commit('removed a')
641
644
        self.assertEqual(a.revno(), 2)
642
645
        self.assertFalse(os.path.exists('a/file'))
643
 
        b.commit('exec a')
 
646
        b_wt.commit('exec a')
644
647
        merge(['b', -1], ['b', 0], this_dir='a')
645
648
        self.assert_(os.path.exists('a/file'))
646
 
        import pdb
647
 
        pdb.set_trace()