47
47
def transform_tree(from_tree, to_tree, interesting_ids=None):
48
48
from_tree.lock_tree_write()
50
merge_inner(from_tree.branch, to_tree, from_tree, ignore_zero=True,
51
interesting_ids=interesting_ids, this_tree=from_tree)
49
operation = OperationWithCleanups(merge_inner)
50
operation.add_cleanup(from_tree.unlock)
51
operation.run_simple(from_tree.branch, to_tree, from_tree,
52
ignore_zero=True, interesting_ids=interesting_ids, this_tree=from_tree)
56
55
class MergeHooks(hooks.Hooks):
455
454
def _add_parent(self):
456
455
new_parents = self.this_tree.get_parent_ids() + [self.other_rev_id]
457
456
new_parent_trees = []
457
operation = OperationWithCleanups(self.this_tree.set_parent_trees)
458
458
for revision_id in new_parents:
460
460
tree = self.revision_tree(revision_id)
465
operation.add_cleanup(tree.unlock)
465
466
new_parent_trees.append((revision_id, tree))
467
self.this_tree.set_parent_trees(new_parent_trees,
468
allow_leftmost_as_ghost=True)
470
for _revision_id, tree in new_parent_trees:
467
operation.run_simple(new_parent_trees, allow_leftmost_as_ghost=True)
474
469
def set_other(self, other_revision, possible_transports=None):
475
470
"""Set the revision and tree to merge from.
626
621
change_reporter=self.change_reporter,
629
def _do_merge_to(self, merge):
624
def _do_merge_to(self):
625
merge = self.make_merger()
630
626
if self.other_branch is not None:
631
627
self.other_branch.update_references(self.this_branch)
646
642
sub_tree.branch.repository.revision_tree(base_revision)
647
643
sub_merge.base_rev_id = base_revision
648
644
sub_merge.do_merge()
650
647
def do_merge(self):
648
operation = OperationWithCleanups(self._do_merge_to)
651
649
self.this_tree.lock_tree_write()
653
if self.base_tree is not None:
654
self.base_tree.lock_read()
656
if self.other_tree is not None:
657
self.other_tree.lock_read()
659
merge = self.make_merger()
660
self._do_merge_to(merge)
662
if self.other_tree is not None:
663
self.other_tree.unlock()
665
if self.base_tree is not None:
666
self.base_tree.unlock()
668
self.this_tree.unlock()
650
operation.add_cleanup(self.this_tree.unlock)
651
if self.base_tree is not None:
652
self.base_tree.lock_read()
653
operation.add_cleanup(self.base_tree.unlock)
654
if self.other_tree is not None:
655
self.other_tree.lock_read()
656
operation.add_cleanup(self.other_tree.unlock)
657
merge = operation.run_simple()
669
658
if len(merge.cooked_conflicts) == 0:
670
659
if not self.ignore_zero and not trace.is_quiet():
671
660
trace.note("All changes applied successfully.")
765
754
warnings.warn("pb argument to Merge3Merger is deprecated")
767
756
def do_merge(self):
757
operation = OperationWithCleanups(self._do_merge)
768
758
self.this_tree.lock_tree_write()
759
operation.add_cleanup(self.this_tree.unlock)
769
760
self.base_tree.lock_read()
761
operation.add_cleanup(self.base_tree.unlock)
770
762
self.other_tree.lock_read()
763
operation.add_cleanup(self.other_tree.unlock)
766
def _do_merge(self, operation):
767
self.tt = transform.TreeTransform(self.this_tree, None)
768
operation.add_cleanup(self.tt.finalize)
769
self._compute_transform()
770
results = self.tt.apply(no_conflicts=True)
771
self.write_modified(results)
772
self.tt = transform.TreeTransform(self.this_tree, None)
774
self._compute_transform()
775
results = self.tt.apply(no_conflicts=True)
776
self.write_modified(results)
778
self.this_tree.add_conflicts(self.cooked_conflicts)
779
except errors.UnsupportedOperation:
784
self.other_tree.unlock()
785
self.base_tree.unlock()
786
self.this_tree.unlock()
773
self.this_tree.add_conflicts(self.cooked_conflicts)
774
except errors.UnsupportedOperation:
788
777
def make_preview_transform(self):
778
operation = OperationWithCleanups(self._make_preview_transform)
789
779
self.base_tree.lock_read()
780
operation.add_cleanup(self.base_tree.unlock)
790
781
self.other_tree.lock_read()
782
operation.add_cleanup(self.other_tree.unlock)
783
return operation.run_simple()
785
def _make_preview_transform(self):
791
786
self.tt = transform.TransformPreview(self.this_tree)
793
self._compute_transform()
795
self.other_tree.unlock()
796
self.base_tree.unlock()
787
self._compute_transform()
799
790
def _compute_transform(self):