47
47
conflict that are not explicitly handled cause an exception and
48
48
terminate the merge.
50
def __init__(self, this_branch, this_tree, base_tree, other_tree,
50
def __init__(self, ignore_zero=False):
52
51
ExceptionConflictHandler.__init__(self)
53
self.this_branch = this_branch
54
self.this_tree = this_tree
55
self.base_tree = base_tree
56
self.other_tree = other_tree
58
53
self.ignore_zero = ignore_zero
59
self.inventory_changes = []
61
def inventory_add(self, id, path):
62
self.this_branch.inventory.add([path])
63
self.inventory_changes[id] = path
65
55
def copy(self, source, dest):
66
56
"""Copy the text and mode of a file
122
111
os.rename(new_file, this_path)
123
112
self.conflict("Diff3 conflict encountered in %s" % this_path)
125
def invent_path(self, file_id, create_dir=False):
126
"""Copies as much of the path as possible from this_tree, substituting
127
pathname elements from other_tree where necessary.
129
path = self.this_tree.id2path()
131
return this_tree.abspath(path)
133
ie = other.inventory[file_id]
134
parent_dir = self.invent_path(ie.parent_id, create_dir=True)
135
path = os.path.join(parent_dir, ie.name)
137
add_dir(self, file_id, path)
139
def add_dir(self, file_id, path):
140
self.clear_path(path)
142
self.this_branch.add([path], [file_id])
143
self.inventory_change[file_id] = path
145
def missing_for_merge(self, file_id, other_path):
147
path = self.invent_path(file_id)
149
self.dump(self.base_tree.get_file(file_id), path)
151
114
def new_contents_conflict(self, filename, other_contents):
152
115
"""Conflicting contents for newly added file."""
153
116
self.copy(other_contents, filename + ".OTHER")
240
203
return self.tree.inventory.has_id(file_id)
242
def abspath(self, filename):
243
return self.tree.filename
245
205
def readonly_path(self, id):
246
206
if id not in self.tree:
390
350
def get_inventory(tree):
391
351
return tree.tree.inventory
393
handler = MergeConflictHander(this_branch, this_tree, base_tree,
394
other_tree, ignore_zero=ignore_zero)
395
353
inv_changes = merge_flex(this_tree, base_tree, other_tree,
396
generate_cset_optimized, get_inventory, handler,
354
generate_cset_optimized, get_inventory,
355
MergeConflictHandler(ignore_zero=ignore_zero),
397
356
merge_factory=merge_factory,
398
357
interesting_ids=interesting_ids)