37
37
from bzrlib.merge import transform_tree, merge_inner, _PlanMerge
38
38
from bzrlib.osutils import basename, pathjoin, file_kind
39
39
from bzrlib.tests import (
40
41
TestCaseWithMemoryTransport,
41
42
TestCaseWithTransport,
138
139
def test_merge_unrelated_retains_root(self):
139
140
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')
141
other_tree = self.make_branch_and_tree('other')
142
self.addCleanup(other_tree.lock_read().unlock)
154
143
merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
155
144
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())
146
with transform.TransformPreview(wt) as merger.tt:
147
merger._compute_transform()
148
new_root_id = merger.tt.final_file_id(merger.tt.root)
149
self.assertEqual(wt.get_root_id(), new_root_id)
161
151
def test_create_rename(self):
162
152
"""Rename an inventory entry while creating the file"""
2260
2250
wt.get_file_text('foo-id'))
2262
2252
def test_modified_symlink(self):
2263
self.requireFeature(tests.SymlinkFeature)
2253
self.requireFeature(features.SymlinkFeature)
2264
2254
# A Create symlink foo => bar
2266
2256
# B C B relinks foo => baz
2305
2295
self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2307
2297
def test_renamed_symlink(self):
2308
self.requireFeature(tests.SymlinkFeature)
2298
self.requireFeature(features.SymlinkFeature)
2309
2299
# A Create symlink foo => bar
2311
2301
# B C B renames foo => barry
2361
2351
self.assertEqual('blah', wt.id2path('foo-id'))
2363
2353
def test_symlink_no_content_change(self):
2364
self.requireFeature(tests.SymlinkFeature)
2354
self.requireFeature(features.SymlinkFeature)
2365
2355
# A Create symlink foo => bar
2367
2357
# B C B relinks foo => baz
2412
2402
self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2414
2404
def test_symlink_this_changed_kind(self):
2415
self.requireFeature(tests.SymlinkFeature)
2405
self.requireFeature(features.SymlinkFeature)
2418
2408
# B C B creates symlink foo => bar
2466
2456
def test_symlink_all_wt(self):
2467
2457
"""Check behavior if all trees are Working Trees."""
2468
self.requireFeature(tests.SymlinkFeature)
2458
self.requireFeature(features.SymlinkFeature)
2469
2459
# The big issue is that entry.symlink_target is None for WorkingTrees.
2470
2460
# So we need to make sure we handle that case correctly.