~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_core.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
            tt.apply()
99
99
            wt.commit('branch commit')
100
100
            wt.flush()
101
 
            if len(wt.branch.revision_history()) != 2:
 
101
            if wt.branch.last_revision_info()[0] != 2:
102
102
                raise AssertionError()
103
103
        self.this.branch.fetch(self.other.branch)
104
104
        other_basis = self.other.branch.basis_tree()
542
542
        """Sucessfully merges unrelated branches with no common names"""
543
543
        wta = self.make_branch_and_tree('a')
544
544
        a = wta.branch
545
 
        file('a/a_file', 'wb').write('contents\n')
 
545
        with file('a/a_file', 'wb') as f: f.write('contents\n')
546
546
        wta.add('a_file')
547
547
        wta.commit('a_revision', allow_pointless=False)
548
548
        wtb = self.make_branch_and_tree('b')
549
549
        b = wtb.branch
550
 
        file('b/b_file', 'wb').write('contents\n')
 
550
        with file('b/b_file', 'wb') as f: f.write('contents\n')
551
551
        wtb.add('b_file')
552
552
        b_rev = wtb.commit('b_revision', allow_pointless=False)
553
553
        wta.merge_from_branch(wtb.branch, b_rev, 'null:')
558
558
        """Sucessfully merges unrelated branches with common names"""
559
559
        wta = self.make_branch_and_tree('a')
560
560
        a = wta.branch
561
 
        file('a/file', 'wb').write('contents\n')
 
561
        with file('a/file', 'wb') as f: f.write('contents\n')
562
562
        wta.add('file')
563
563
        wta.commit('a_revision', allow_pointless=False)
564
564
        wtb = self.make_branch_and_tree('b')
565
565
        b = wtb.branch
566
 
        file('b/file', 'wb').write('contents\n')
 
566
        with file('b/file', 'wb') as f: f.write('contents\n')
567
567
        wtb.add('file')
568
568
        b_rev = wtb.commit('b_revision', allow_pointless=False)
569
569
        wta.merge_from_branch(wtb.branch, b_rev, 'null:')
573
573
 
574
574
    def test_merge_deleted_conflicts(self):
575
575
        wta = self.make_branch_and_tree('a')
576
 
        file('a/file', 'wb').write('contents\n')
 
576
        with file('a/file', 'wb') as f: f.write('contents\n')
577
577
        wta.add('file')
578
578
        wta.commit('a_revision', allow_pointless=False)
579
579
        self.run_bzr('branch a b')
580
580
        os.remove('a/file')
581
581
        wta.commit('removed file', allow_pointless=False)
582
 
        file('b/file', 'wb').write('changed contents\n')
 
582
        with file('b/file', 'wb') as f: f.write('changed contents\n')
583
583
        wtb = WorkingTree.open('b')
584
584
        wtb.commit('changed file', allow_pointless=False)
585
585
        wtb.merge_from_branch(wta.branch, wta.branch.last_revision(),
589
589
    def test_merge_metadata_vs_deletion(self):
590
590
        """Conflict deletion vs metadata change"""
591
591
        a_wt = self.make_branch_and_tree('a')
592
 
        file('a/file', 'wb').write('contents\n')
 
592
        with file('a/file', 'wb') as f: f.write('contents\n')
593
593
        a_wt.add('file')
594
594
        a_wt.commit('r0')
595
595
        self.run_bzr('branch a b')
605
605
 
606
606
    def test_merge_swapping_renames(self):
607
607
        a_wt = self.make_branch_and_tree('a')
608
 
        file('a/un','wb').write('UN')
609
 
        file('a/deux','wb').write('DEUX')
 
608
        with file('a/un','wb') as f: f.write('UN')
 
609
        with file('a/deux','wb') as f: f.write('DEUX')
610
610
        a_wt.add('un', 'un-id')
611
611
        a_wt.add('deux', 'deux-id')
612
612
        a_wt.commit('r0', rev_id='r0')
626
626
 
627
627
    def test_merge_delete_and_add_same(self):
628
628
        a_wt = self.make_branch_and_tree('a')
629
 
        file('a/file', 'wb').write('THIS')
 
629
        with file('a/file', 'wb') as f: f.write('THIS')
630
630
        a_wt.add('file')
631
631
        a_wt.commit('r0')
632
632
        self.run_bzr('branch a b')
633
633
        b_wt = WorkingTree.open('b')
634
634
        os.remove('b/file')
635
635
        b_wt.commit('r1')
636
 
        file('b/file', 'wb').write('THAT')
 
636
        with file('b/file', 'wb') as f: f.write('THAT')
637
637
        b_wt.add('file')
638
638
        b_wt.commit('r2')
639
639
        a_wt.merge_from_branch(b_wt.branch, b_wt.branch.last_revision(),
656
656
        $ bzr commit
657
657
        """
658
658
        a_wt = self.make_branch_and_tree('a')
659
 
        file('a/foo', 'wb').write('A/FOO')
 
659
        with file('a/foo', 'wb') as f: f.write('A/FOO')
660
660
        a_wt.add('foo')
661
661
        a_wt.commit('added foo')
662
662
        self.run_bzr('branch a b')
663
663
        b_wt = WorkingTree.open('b')
664
664
        b_wt.rename_one('foo', 'bar')
665
 
        file('b/foo', 'wb').write('B/FOO')
 
665
        with file('b/foo', 'wb') as f: f.write('B/FOO')
666
666
        b_wt.add('foo')
667
667
        b_wt.commit('moved foo to bar, added new foo')
668
668
        a_wt.merge_from_branch(b_wt.branch, b_wt.branch.last_revision(),
685
685
        """
686
686
        os.mkdir('a')
687
687
        a_wt = self.make_branch_and_tree('a')
688
 
        file('a/foo', 'wb').write('A/FOO')
 
688
        with file('a/foo', 'wb') as f: f.write('A/FOO')
689
689
        a_wt.add('foo')
690
690
        a_wt.commit('added foo')
691
691
        self.run_bzr('branch a b')
714
714
        """
715
715
        a_wt = self.make_branch_and_tree('a')
716
716
        os.mkdir('a/foo')
717
 
        file('a/foo/bar', 'wb').write('A/FOO/BAR')
 
717
        with file('a/foo/bar', 'wb') as f: f.write('A/FOO/BAR')
718
718
        a_wt.add('foo')
719
719
        a_wt.add('foo/bar')
720
720
        a_wt.commit('added foo/bar')
743
743
        $ bzr commit
744
744
        """
745
745
        a_wt = self.make_branch_and_tree('a')
746
 
        file('a/foo', 'wb').write('A/FOO')
747
 
        file('a/bar', 'wb').write('A/BAR')
 
746
        with file('a/foo', 'wb') as f: f.write('A/FOO')
 
747
        with file('a/bar', 'wb') as f: f.write('A/BAR')
748
748
        a_wt.add('foo')
749
749
        a_wt.add('bar')
750
750
        a_wt.commit('added foo and bar')