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'])
129
wt.commit('tree with root')
130
merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
131
this_branch=wt.branch,
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())
138
def test_merge_unrelated_retains_root(self):
139
wt = self.make_branch_and_tree('tree')
140
root_id_before_merge = wt.get_root_id()
141
other_tree = self.make_branch_and_tree('other')
142
# Do a commit so there is something to merge
143
other_tree.commit('commit other')
144
self.assertNotEquals(root_id_before_merge, other_tree.get_root_id())
145
wt.merge_from_branch(other_tree.branch,
146
from_revision=_mod_revision.NULL_REVISION)
147
self.assertEqual(root_id_before_merge, wt.get_root_id())
149
def test_merge_preview_unrelated_retains_root(self):
150
wt = self.make_branch_and_tree('tree')
151
other_tree = self.make_branch_and_tree('other')
152
# Do a commit so there is something to merge
153
other_tree.commit('commit other')
154
merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
155
this_branch=wt.branch,
157
with merger.make_preview_transform() as tt:
158
preview = tt.get_preview_tree()
159
self.assertEqual(wt.get_root_id(), preview.get_root_id())
161
124
def test_create_rename(self):
162
125
"""Rename an inventory entry while creating the file"""
163
126
tree =self.make_branch_and_tree('.')
424
387
'>>>>>>> MERGE-SOURCE\n',
427
def test_merge_reverse_revision_range(self):
428
tree = self.make_branch_and_tree(".")
430
self.addCleanup(tree.unlock)
431
self.build_tree(['a'])
433
tree.commit("added a")
434
first_rev = tree.branch.revision_history()[0]
435
merger = _mod_merge.Merger.from_revision_ids(None, tree,
436
_mod_revision.NULL_REVISION,
438
merger.merge_type = _mod_merge.Merge3Merger
439
merger.interesting_files = 'a'
440
conflict_count = merger.do_merge()
441
self.assertEqual(0, conflict_count)
443
self.assertPathDoesNotExist("a")
445
self.assertPathExists("a")
447
390
def test_make_merger(self):
448
391
this_tree = self.make_branch_and_tree('this')
449
392
this_tree.commit('rev1', rev_id='rev1')
514
457
tree_file.close()
516
def test_merge_require_tree_root(self):
517
tree = self.make_branch_and_tree(".")
519
self.addCleanup(tree.unlock)
520
self.build_tree(['a'])
522
tree.commit("added a")
523
old_root_id = tree.get_root_id()
524
first_rev = tree.branch.revision_history()[0]
525
merger = _mod_merge.Merger.from_revision_ids(None, tree,
526
_mod_revision.NULL_REVISION,
528
merger.merge_type = _mod_merge.Merge3Merger
529
conflict_count = merger.do_merge()
530
self.assertEqual(0, conflict_count)
531
self.assertEquals(set([old_root_id]), tree.all_file_ids())
532
tree.set_parent_ids([])
534
459
def test_merge_add_into_deleted_root(self):
535
460
# Yes, people actually do this. And report bugs if it breaks.
536
461
source = self.make_branch_and_tree('source', format='rich-root-pack')
1902
1827
builder.build_snapshot('C-id', ['A-id'], [])
1903
1828
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1904
1829
[('unversion', 'a-id'),
1906
1830
('add', (u'a', 'a-id', 'directory', None))])
1907
1831
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1908
1832
merge_obj = self.make_merge_obj(builder, 'E-id')
1926
1850
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1927
1851
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1928
1852
[('unversion', 'a-id'),
1930
1853
('add', (u'a', 'a-id', 'directory', None))])
1931
1854
merge_obj = self.make_merge_obj(builder, 'E-id')
1932
1855
entries = list(merge_obj._entries_lca())
2941
2864
def get_merger_factory(self):
2942
2865
# Allows the inner methods to access the test attributes
2945
2868
class FooMerger(_mod_merge.ConfigurableFileMerger):
2946
2869
name_prefix = "foo"
2947
2870
default_files = ['bar']
2949
2872
def merge_text(self, params):
2950
calls.append('merge_text')
2873
test.calls.append('merge_text')
2951
2874
return ('not_applicable', None)
2953
2876
def factory(merger):