479
480
def associated_filenames(self):
480
481
return [self.path + suffix for suffix in ('.BASE', '.OTHER')]
482
# FIXME: I smell something weird here and it seems we should be able to be
483
# more coherent with some other conflict ? bzr *did* a choice there but
484
# neither action_take_this nor action_take_other reflect that...
483
def _take_it(self, tt, suffix_to_remove):
484
"""Resolve the conflict.
486
:param tt: The TreeTransform where the conflict is resolved.
487
:param suffix_to_remove: Either 'THIS' or 'OTHER'
489
The resolution is symmetric, when taking THIS, OTHER is deleted and
490
item.THIS is renamed into item and vice-versa.
493
# Delete 'item.THIS' or 'item.OTHER' depending on
496
tt.trans_id_tree_path(self.path + '.' + suffix_to_remove))
497
except errors.NoSuchFile:
498
# There are valid cases where 'item.suffix_to_remove' either
499
# never existed or was already deleted (including the case
500
# where the user deleted it)
502
# Rename 'item.suffix_to_remove' (note that if
503
# 'item.suffix_to_remove' has been deleted, this is a no-op)
504
this_tid = tt.trans_id_file_id(self.file_id)
505
parent_tid = tt.get_tree_parent(this_tid)
506
tt.adjust_path(self.path, parent_tid, this_tid)
509
def _take_it_with_cleanups(self, tree, suffix_to_remove):
510
tt = transform.TreeTransform(tree)
511
op = cleanup.OperationWithCleanups(self._take_it)
512
op.add_cleanup(tt.finalize)
513
op.run_simple(tt, suffix_to_remove)
486
515
def action_take_this(self, tree):
487
tree.remove([self.path + '.OTHER'], force=True, keep_files=False)
516
self._take_it_with_cleanups(tree, 'OTHER')
489
518
def action_take_other(self, tree):
490
tree.remove([self.path], force=True, keep_files=False)
519
self._take_it_with_cleanups(tree, 'THIS')
494
522
# FIXME: TextConflict is about a single file-id, there never is a conflict_path