~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Andrew Bennetts
  • Date: 2008-03-17 17:16:11 UTC
  • mfrom: (3290 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080317171611-o9wdrnf0m7qwo198
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from bzrlib.errors import UnrelatedBranches, NoCommits, BzrCommandError
33
33
from bzrlib.merge import transform_tree, merge_inner, _PlanMerge
34
34
from bzrlib.osutils import pathjoin, file_kind
35
 
from bzrlib.revision import common_ancestor
36
35
from bzrlib.tests import TestCaseWithTransport, TestCaseWithMemoryTransport
37
36
from bzrlib.trace import (enable_test_log, disable_test_log)
38
37
from bzrlib.workingtree import WorkingTree
106
105
        """Merge base is sane when two unrelated branches are merged"""
107
106
        wt1, br2 = self.test_pending_with_null()
108
107
        wt1.commit("blah")
109
 
        last = wt1.branch.last_revision()
110
 
        self.assertEqual(common_ancestor(last, last, wt1.branch.repository), last)
 
108
        wt1.lock_read()
 
109
        try:
 
110
            last = wt1.branch.last_revision()
 
111
            last2 = br2.last_revision()
 
112
            graph = wt1.branch.repository.get_graph()
 
113
            self.assertEqual(last2, graph.find_unique_lca(last, last2))
 
114
        finally:
 
115
            wt1.unlock()
111
116
 
112
117
    def test_create_rename(self):
113
118
        """Rename an inventory entry while creating the file"""
352
357
        merger.merge_type = _mod_merge.Merge3Merger
353
358
        merger.do_merge()
354
359
 
 
360
    def test_merge3_will_detect_cherrypick(self):
 
361
        this_tree = self.make_branch_and_tree('this')
 
362
        self.build_tree_contents([('this/file', "a\n")])
 
363
        this_tree.add('file')
 
364
        this_tree.commit('rev1')
 
365
        other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
 
366
        self.build_tree_contents([('other/file', "a\nb\n")])
 
367
        other_tree.commit('rev2b', rev_id='rev2b')
 
368
        self.build_tree_contents([('other/file', "a\nb\nc\n")])
 
369
        other_tree.commit('rev3b', rev_id='rev3b')
 
370
        this_tree.lock_write()
 
371
        self.addCleanup(this_tree.unlock)
 
372
 
 
373
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
374
            this_tree, 'rev3b', 'rev2b', other_tree.branch)
 
375
        merger.merge_type = _mod_merge.Merge3Merger
 
376
        merger.do_merge()
 
377
        self.assertFileEqual('a\n'
 
378
                             '<<<<<<< TREE\n'
 
379
                             '=======\n'
 
380
                             'c\n'
 
381
                             '>>>>>>> MERGE-SOURCE\n',
 
382
                             'this/file')
 
383
 
355
384
    def test_make_merger(self):
356
385
        this_tree = self.make_branch_and_tree('this')
357
386
        this_tree.commit('rev1', rev_id='rev1')