/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/test_merge_core.py

  • Committer: Robert Collins
  • Date: 2005-11-28 05:13:41 UTC
  • mfrom: (1185.33.54 merge-recovered)
  • Revision ID: robertc@robertcollins.net-20051128051341-059936f2f29a12c8
Merge from Martin. Adjust check to work with HTTP again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import stat
6
6
import sys
7
7
 
8
 
from bzrlib.selftest import TestCaseInTempDir, TestCase
 
8
from bzrlib.tests import TestCaseInTempDir, TestCase
9
9
from bzrlib.branch import ScratchBranch, Branch
10
10
from bzrlib.errors import (NotBranchError, NotVersionedError,
11
11
                           WorkingTreeNotRevision, BzrCommandError)
19
19
    get_contents, ReplaceContents, ChangeExecFlag
20
20
from bzrlib.clone import copy_branch
21
21
from bzrlib.merge import merge
 
22
from bzrlib.workingtree import WorkingTree
22
23
 
23
24
 
24
25
class FalseTree(object):
535
536
 
536
537
    def test_trivial_star_merge(self):
537
538
        """Test that merges in a star shape Just Work.""" 
538
 
        from bzrlib.add import smart_add_branch, add_reporter_null
 
539
        from bzrlib.add import smart_add_tree, add_reporter_null
539
540
        from bzrlib.clone import copy_branch
540
541
        from bzrlib.merge import merge
541
542
        # John starts a branch
542
543
        self.build_tree(("original/", "original/file1", "original/file2"))
543
544
        branch = Branch.initialize("original")
544
 
        smart_add_branch(branch, ["original"], True, add_reporter_null)
545
 
        branch.working_tree().commit("start branch.", verbose=False)
 
545
        tree = WorkingTree('original', branch)
 
546
        smart_add_tree(tree, ["original"], True, add_reporter_null)
 
547
        tree.commit("start branch.", verbose=False)
546
548
        # Mary branches it.
547
549
        self.build_tree(("mary/",))
548
550
        copy_branch(branch, "mary")
573
575
        os.mkdir('a')
574
576
        a = Branch.initialize('a')
575
577
        file('a/file', 'wb').write('contents\n')
576
 
        a.add('file')
 
578
        a.working_tree().add('file')
577
579
        a.working_tree().commit('base revision', allow_pointless=False)
578
580
        b = copy_branch(a, 'b')
579
581
        file('a/file', 'wb').write('other contents\n')
603
605
        os.mkdir('a')
604
606
        a = Branch.initialize('a')
605
607
        file('a/a_file', 'wb').write('contents\n')
606
 
        a.add('a_file')
 
608
        a.working_tree().add('a_file')
607
609
        a.working_tree().commit('a_revision', allow_pointless=False)
608
610
        os.mkdir('b')
609
611
        b = Branch.initialize('b')
610
612
        file('b/b_file', 'wb').write('contents\n')
611
 
        b.add('b_file')
 
613
        b.working_tree().add('b_file')
612
614
        b.working_tree().commit('b_revision', allow_pointless=False)
613
615
        merge(['b', -1], ['b', 0], this_dir='a')
614
616
        self.assert_(os.path.lexists('a/b_file'))
620
622
        os.mkdir('a')
621
623
        a = Branch.initialize('a')
622
624
        file('a/file', 'wb').write('contents\n')
623
 
        a.add('file')
 
625
        a.working_tree().add('file')
624
626
        a.working_tree().commit('a_revision', allow_pointless=False)
625
627
        os.mkdir('b')
626
628
        b = Branch.initialize('b')
627
629
        file('b/file', 'wb').write('contents\n')
628
 
        b.add('file')
 
630
        b.working_tree().add('file')
629
631
        b.working_tree().commit('b_revision', allow_pointless=False)
630
632
        merge(['b', -1], ['b', 0], this_dir='a')
631
633
        self.assert_(os.path.lexists('a/file'))
632
634
        self.assert_(os.path.lexists('a/file.moved'))
633
635
        self.assertEqual(a.working_tree().pending_merges(), [b.last_revision()])
634
636
 
 
637
    def test_merge_deleted_conflicts(self):
 
638
        os.mkdir('a')
 
639
        a = Branch.initialize('a')
 
640
        file('a/file', 'wb').write('contents\n')
 
641
        a.working_tree().add('file')
 
642
        a.working_tree().commit('a_revision', allow_pointless=False)
 
643
        del a
 
644
        self.run_bzr('branch', 'a', 'b')
 
645
        a = Branch.open('a')
 
646
        os.remove('a/file')
 
647
        a.working_tree().commit('removed file', allow_pointless=False)
 
648
        file('b/file', 'wb').write('changed contents\n')
 
649
        b = Branch.open('b')
 
650
        b.working_tree().commit('changed file', allow_pointless=False)
 
651
        merge(['a', -1], ['a', 1], this_dir='b')
 
652
        self.failIf(os.path.lexists('b/file'))
 
653
 
635
654
    def test_merge_metadata_vs_deletion(self):
636
655
        """Conflict deletion vs metadata change"""
637
656
        os.mkdir('a')
638
657
        a = Branch.initialize('a')
639
658
        file('a/file', 'wb').write('contents\n')
640
 
        a.add('file')
641
659
        a_wt = a.working_tree()
 
660
        a_wt.add('file')
642
661
        a_wt.commit('r0')
643
662
        copy_branch(a, 'b')
644
663
        b = Branch.open('b')
651
670
        b_wt.commit('exec a')
652
671
        merge(['b', -1], ['b', 0], this_dir='a')
653
672
        self.assert_(os.path.exists('a/file'))
 
673