941
941
walker = _mod_tree.MultiWalker(self.other_tree, self._lca_trees)
943
base_inventory = self.base_tree.inventory
944
this_inventory = self.this_tree.inventory
943
base_inventory = self.base_tree.root_inventory
944
this_inventory = self.this_tree.root_inventory
945
945
for path, file_id, other_ie, lca_values in walker.iter_all():
946
946
# Is this modified at all from any of the other trees?
947
947
if other_ie is None:
1081
@deprecated_method(deprecated_in((2, 4, 0)))
1083
if self.tt.final_kind(self.tt.root) is None:
1084
self.tt.cancel_deletion(self.tt.root)
1085
if self.tt.final_file_id(self.tt.root) is None:
1086
self.tt.version_file(self.tt.tree_file_id(self.tt.root),
1088
other_root_file_id = self.other_tree.get_root_id()
1089
if other_root_file_id is None:
1091
other_root = self.tt.trans_id_file_id(other_root_file_id)
1092
if other_root == self.tt.root:
1094
if self.this_tree.inventory.has_id(
1095
self.other_tree.inventory.root.file_id):
1096
# the other tree's root is a non-root in the current tree (as
1097
# when a previously unrelated branch is merged into another)
1099
if self.tt.final_kind(other_root) is not None:
1100
other_root_is_present = True
1102
# other_root doesn't have a physical representation. We still need
1103
# to move any references to the actual root of the tree.
1104
other_root_is_present = False
1105
# 'other_tree.inventory.root' is not present in this tree. We are
1106
# calling adjust_path for children which *want* to be present with a
1107
# correct place to go.
1108
for _, child in self.other_tree.inventory.root.children.iteritems():
1109
trans_id = self.tt.trans_id_file_id(child.file_id)
1110
if not other_root_is_present:
1111
if self.tt.final_kind(trans_id) is not None:
1112
# The item exist in the final tree and has a defined place
1115
# Move the item into the root
1117
final_name = self.tt.final_name(trans_id)
1118
except errors.NoFinalPath:
1119
# This file is not present anymore, ignore it.
1121
self.tt.adjust_path(final_name, self.tt.root, trans_id)
1122
if other_root_is_present:
1123
self.tt.cancel_creation(other_root)
1124
self.tt.cancel_versioning(other_root)
1126
1081
def write_modified(self, results):
1127
1082
modified_hashes = {}
1128
1083
for path in results.modified_paths:
1238
1193
# At this point, the lcas disagree, and the tip disagree
1239
1194
return 'conflict'
1242
@deprecated_method(deprecated_in((2, 2, 0)))
1243
def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
1244
"""Do a three-way test on a scalar.
1245
Return "this", "other" or "conflict", depending whether a value wins.
1247
key_base = key(base_tree, file_id)
1248
key_other = key(other_tree, file_id)
1249
#if base == other, either they all agree, or only THIS has changed.
1250
if key_base == key_other:
1252
key_this = key(this_tree, file_id)
1253
# "Ambiguous clean merge"
1254
if key_this == key_other:
1256
elif key_this == key_base:
1261
1196
def merge_names(self, file_id):
1262
1197
def get_entry(tree):
1263
if tree.has_id(file_id):
1264
return tree.inventory[file_id]
1199
return tree.root_inventory[file_id]
1200
except errors.NoSuchId:
1267
1202
this_entry = get_entry(self.this_tree)
1268
1203
other_entry = get_entry(self.other_tree)
1941
1876
def _entries_to_incorporate(self):
1942
1877
"""Yields pairs of (inventory_entry, new_parent)."""
1943
other_inv = self.other_tree.inventory
1878
other_inv = self.other_tree.root_inventory
1944
1879
subdir_id = other_inv.path2id(self._source_subpath)
1945
1880
if subdir_id is None:
1946
1881
# XXX: The error would be clearer if it gave the URL of the source
1948
1883
raise PathNotInTree(self._source_subpath, "Source tree")
1949
1884
subdir = other_inv[subdir_id]
1950
1885
parent_in_target = osutils.dirname(self._target_subdir)
1951
target_id = self.this_tree.inventory.path2id(parent_in_target)
1886
target_id = self.this_tree.path2id(parent_in_target)
1952
1887
if target_id is None:
1953
1888
raise PathNotInTree(self._target_subdir, "Target tree")
1954
1889
name_in_target = osutils.basename(self._target_subdir)
1955
1890
merge_into_root = subdir.copy()
1956
1891
merge_into_root.name = name_in_target
1957
if self.this_tree.inventory.has_id(merge_into_root.file_id):
1892
if self.this_tree.has_id(merge_into_root.file_id):
1958
1893
# Give the root a new file-id.
1959
1894
# This can happen fairly easily if the directory we are
1960
1895
# incorporating is the root, and both trees have 'TREE_ROOT' as