1051
1051
other_root = self.tt.trans_id_file_id(other_root_file_id)
1052
1052
if other_root == self.tt.root:
1054
if self.other_tree.inventory.root.file_id in self.this_tree.inventory:
1055
# the other tree's root is a non-root in the current tree (as when
1056
# a previously unrelated branch is merged into another)
1055
1059
self.tt.final_kind(other_root)
1056
except errors.NoSuchFile:
1058
if self.this_tree.has_id(self.other_tree.inventory.root.file_id):
1059
# the other tree's root is a non-root in the current tree
1061
self.reparent_children(self.other_tree.inventory.root, self.tt.root)
1062
self.tt.cancel_creation(other_root)
1063
self.tt.cancel_versioning(other_root)
1065
def reparent_children(self, ie, target):
1066
for thing, child in ie.children.iteritems():
1060
other_root_is_present = True
1062
# other_root doesn't have a physical representation. We still need
1063
# to move any references to the actual root of the tree.
1064
other_root_is_present = False
1065
# 'other_tree.inventory.root' is not present in this tree. We are
1066
# calling adjust_path for children which *want* to be present with a
1067
# correct place to go.
1068
for thing, child in self.other_tree.inventory.root.children.iteritems():
1067
1069
trans_id = self.tt.trans_id_file_id(child.file_id)
1068
self.tt.adjust_path(self.tt.final_name(trans_id), target, trans_id)
1070
if not other_root_is_present:
1071
# FIXME: Make final_kind returns None instead of raising
1072
# NoSuchFile to avoid the ugly construct below -- vila 20100402
1074
self.tt.final_kind(trans_id)
1075
# The item exist in the final tree and has a defined place
1078
except errors.NoSuchFile, e:
1080
# Move the item into the root
1081
self.tt.adjust_path(self.tt.final_name(trans_id),
1082
self.tt.root, trans_id)
1083
if other_root_is_present:
1084
self.tt.cancel_creation(other_root)
1085
self.tt.cancel_versioning(other_root)
1070
1087
def write_modified(self, results):
1071
1088
modified_hashes = {}