447
447
def _add_parent(self):
448
448
new_parents = self.this_tree.get_parent_ids() + [self.other_rev_id]
449
449
new_parent_trees = []
450
operation = cleanup.OperationWithCleanups(
451
self.this_tree.set_parent_trees)
452
for revision_id in new_parents:
454
tree = self.revision_tree(revision_id)
455
except errors.NoSuchRevision:
459
operation.add_cleanup(tree.unlock)
460
new_parent_trees.append((revision_id, tree))
461
operation.run_simple(new_parent_trees, allow_leftmost_as_ghost=True)
450
with cleanup.ExitStack() as stack:
451
for revision_id in new_parents:
453
tree = self.revision_tree(revision_id)
454
except errors.NoSuchRevision:
457
stack.enter_context(tree.lock_read())
458
new_parent_trees.append((revision_id, tree))
459
self.this_tree.set_parent_trees(new_parent_trees, allow_leftmost_as_ghost=True)
463
461
def set_other(self, other_revision, possible_transports=None):
464
462
"""Set the revision and tree to merge from.
658
656
def do_merge(self):
659
operation = cleanup.OperationWithCleanups(self._do_merge_to)
660
self.this_tree.lock_tree_write()
661
operation.add_cleanup(self.this_tree.unlock)
662
if self.base_tree is not None:
663
self.base_tree.lock_read()
664
operation.add_cleanup(self.base_tree.unlock)
665
if self.other_tree is not None:
666
self.other_tree.lock_read()
667
operation.add_cleanup(self.other_tree.unlock)
668
merge = operation.run_simple()
657
with cleanup.ExitStack() as stack:
658
stack.enter_context(self.this_tree.lock_tree_write())
659
if self.base_tree is not None:
660
stack.enter_context(self.base_tree.lock_read())
661
if self.other_tree is not None:
662
stack.enter_context(self.other_tree.lock_read())
663
merge = self._do_merge_to()
669
664
if len(merge.cooked_conflicts) == 0:
670
665
if not self.ignore_zero and not trace.is_quiet():
671
666
trace.note(gettext("All changes applied successfully."))
761
756
def do_merge(self):
762
operation = cleanup.OperationWithCleanups(self._do_merge)
763
self.working_tree.lock_tree_write()
764
operation.add_cleanup(self.working_tree.unlock)
765
self.this_tree.lock_read()
766
operation.add_cleanup(self.this_tree.unlock)
767
self.base_tree.lock_read()
768
operation.add_cleanup(self.base_tree.unlock)
769
self.other_tree.lock_read()
770
operation.add_cleanup(self.other_tree.unlock)
773
def _do_merge(self, operation):
774
self.tt = self.working_tree.get_transform()
775
operation.add_cleanup(self.tt.finalize)
776
self._compute_transform()
777
results = self.tt.apply(no_conflicts=True)
778
self.write_modified(results)
780
self.working_tree.add_conflicts(self.cooked_conflicts)
781
except errors.UnsupportedOperation:
757
with cleanup.ExitStack() as stack:
758
stack.enter_context(self.working_tree.lock_tree_write())
759
stack.enter_context(self.this_tree.lock_read())
760
stack.enter_context(self.base_tree.lock_read())
761
stack.enter_context(self.other_tree.lock_read())
762
self.tt = self.working_tree.get_transform()
763
stack.enter_context(self.tt)
764
self._compute_transform()
765
results = self.tt.apply(no_conflicts=True)
766
self.write_modified(results)
768
self.working_tree.add_conflicts(self.cooked_conflicts)
769
except errors.UnsupportedOperation:
784
772
def make_preview_transform(self):
785
773
with self.base_tree.lock_read(), self.other_tree.lock_read():
1563
1551
if other_parent is None or other_name is None:
1564
1552
other_path = '<deleted>'
1566
if other_parent == self.other_tree.get_root_id():
1554
if other_parent == self.other_tree.path2id(''):
1567
1555
# The tree transform doesn't know about the other root,
1568
1556
# so we special case here to avoid a NoFinalPath