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'])
130
wt.commit('tree with root')
131
merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
132
this_branch=wt.branch,
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())
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())
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,
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())
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',
428
def test_merge_reverse_revision_range(self):
429
tree = self.make_branch_and_tree(".")
431
self.addCleanup(tree.unlock)
432
self.build_tree(['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,
439
merger.merge_type = _mod_merge.Merge3Merger
440
merger.interesting_files = 'a'
441
conflict_count = merger.do_merge()
442
self.assertEqual(0, conflict_count)
444
self.assertPathDoesNotExist("a")
446
self.assertPathExists("a")
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')
458
515
tree_file.close()
517
def test_merge_require_tree_root(self):
518
tree = self.make_branch_and_tree(".")
520
self.addCleanup(tree.unlock)
521
self.build_tree(['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,
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([])
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')