~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-13 16:25:08 UTC
  • mfrom: (5954.4.12 merge-into-empty)
  • Revision ID: pqm@pqm.ubuntu.com-20110613162508-yyvo3qc06t9d2wwf
Support merging into empty tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
        finally:
122
122
            wt1.unlock()
123
123
 
 
124
    def test_merge_into_null_tree(self):
 
125
        wt = self.make_branch_and_tree('tree')
 
126
        null_tree = wt.basis_tree()
 
127
        self.build_tree(['tree/file'])
 
128
        wt.add('file')
 
129
        wt.commit('tree with root')
 
130
        merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
 
131
                                         this_branch=wt.branch,
 
132
                                         do_merge=False)
 
133
        with merger.make_preview_transform() as tt:
 
134
            self.assertEqual([], tt.find_conflicts())
 
135
            preview = tt.get_preview_tree()
 
136
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
137
 
124
138
    def test_create_rename(self):
125
139
        """Rename an inventory entry while creating the file"""
126
140
        tree =self.make_branch_and_tree('.')
387
401
                             '>>>>>>> MERGE-SOURCE\n',
388
402
                             'this/file')
389
403
 
 
404
    def test_merge_reverse_revision_range(self):
 
405
        tree = self.make_branch_and_tree(".")
 
406
        tree.lock_write()
 
407
        self.addCleanup(tree.unlock)
 
408
        self.build_tree(['a'])
 
409
        tree.add('a')
 
410
        tree.commit("added a")
 
411
        first_rev = tree.branch.revision_history()[0]
 
412
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
 
413
                                          _mod_revision.NULL_REVISION,
 
414
                                          first_rev)
 
415
        merger.merge_type = _mod_merge.Merge3Merger
 
416
        merger.interesting_files = 'a'
 
417
        conflict_count = merger.do_merge()
 
418
        self.assertEqual(0, conflict_count)
 
419
 
 
420
        self.assertPathDoesNotExist("a")
 
421
        tree.revert()
 
422
        self.assertPathExists("a")
 
423
 
390
424
    def test_make_merger(self):
391
425
        this_tree = self.make_branch_and_tree('this')
392
426
        this_tree.commit('rev1', rev_id='rev1')