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

Move all features to bzrlib.tests.features in 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        finally:
123
123
            wt1.unlock()
124
124
 
 
125
    def test_merge_into_null_tree(self):
 
126
        wt = self.make_branch_and_tree('tree')
 
127
        null_tree = wt.basis_tree()
 
128
        self.build_tree(['tree/file'])
 
129
        wt.add('file')
 
130
        wt.commit('tree with root')
 
131
        merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
 
132
                                         this_branch=wt.branch,
 
133
                                         do_merge=False)
 
134
        with merger.make_preview_transform() as tt:
 
135
            self.assertEqual([], tt.find_conflicts())
 
136
            preview = tt.get_preview_tree()
 
137
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
138
 
 
139
    def test_merge_unrelated_retains_root(self):
 
140
        wt = self.make_branch_and_tree('tree')
 
141
        root_id_before_merge = wt.get_root_id()
 
142
        other_tree = self.make_branch_and_tree('other')
 
143
        # Do a commit so there is something to merge
 
144
        other_tree.commit('commit other')
 
145
        self.assertNotEquals(root_id_before_merge, other_tree.get_root_id())
 
146
        wt.merge_from_branch(other_tree.branch,
 
147
                             from_revision=_mod_revision.NULL_REVISION)
 
148
        self.assertEqual(root_id_before_merge, wt.get_root_id())
 
149
 
 
150
    def test_merge_preview_unrelated_retains_root(self):
 
151
        wt = self.make_branch_and_tree('tree')
 
152
        other_tree = self.make_branch_and_tree('other')
 
153
        # Do a commit so there is something to merge
 
154
        other_tree.commit('commit other')
 
155
        merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
 
156
                                         this_branch=wt.branch,
 
157
                                         do_merge=False)
 
158
        with merger.make_preview_transform() as tt:
 
159
            preview = tt.get_preview_tree()
 
160
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
161
 
125
162
    def test_create_rename(self):
126
163
        """Rename an inventory entry while creating the file"""
127
164
        tree =self.make_branch_and_tree('.')
388
425
                             '>>>>>>> MERGE-SOURCE\n',
389
426
                             'this/file')
390
427
 
 
428
    def test_merge_reverse_revision_range(self):
 
429
        tree = self.make_branch_and_tree(".")
 
430
        tree.lock_write()
 
431
        self.addCleanup(tree.unlock)
 
432
        self.build_tree(['a'])
 
433
        tree.add('a')
 
434
        tree.commit("added a")
 
435
        first_rev = tree.branch.revision_history()[0]
 
436
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
 
437
                                          _mod_revision.NULL_REVISION,
 
438
                                          first_rev)
 
439
        merger.merge_type = _mod_merge.Merge3Merger
 
440
        merger.interesting_files = 'a'
 
441
        conflict_count = merger.do_merge()
 
442
        self.assertEqual(0, conflict_count)
 
443
 
 
444
        self.assertPathDoesNotExist("a")
 
445
        tree.revert()
 
446
        self.assertPathExists("a")
 
447
 
391
448
    def test_make_merger(self):
392
449
        this_tree = self.make_branch_and_tree('this')
393
450
        this_tree.commit('rev1', rev_id='rev1')
457
514
        finally:
458
515
            tree_file.close()
459
516
 
 
517
    def test_merge_require_tree_root(self):
 
518
        tree = self.make_branch_and_tree(".")
 
519
        tree.lock_write()
 
520
        self.addCleanup(tree.unlock)
 
521
        self.build_tree(['a'])
 
522
        tree.add('a')
 
523
        tree.commit("added a")
 
524
        old_root_id = tree.get_root_id()
 
525
        first_rev = tree.branch.revision_history()[0]
 
526
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
 
527
                                          _mod_revision.NULL_REVISION,
 
528
                                          first_rev)
 
529
        merger.merge_type = _mod_merge.Merge3Merger
 
530
        conflict_count = merger.do_merge()
 
531
        self.assertEqual(0, conflict_count)
 
532
        self.assertEquals(set([old_root_id]), tree.all_file_ids())
 
533
        tree.set_parent_ids([])
 
534
 
460
535
    def test_merge_add_into_deleted_root(self):
461
536
        # Yes, people actually do this.  And report bugs if it breaks.
462
537
        source = self.make_branch_and_tree('source', format='rich-root-pack')