47
46
def transform_tree(from_tree, to_tree, interesting_ids=None):
48
47
from_tree.lock_tree_write()
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)
49
merge_inner(from_tree.branch, to_tree, from_tree, ignore_zero=True,
50
interesting_ids=interesting_ids, this_tree=from_tree)
55
55
class MergeHooks(hooks.Hooks):
465
operation.add_cleanup(tree.unlock)
466
465
new_parent_trees.append((revision_id, tree))
467
operation.run_simple(new_parent_trees, allow_leftmost_as_ghost=True)
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:
469
474
def set_other(self, other_revision, possible_transports=None):
470
475
"""Set the revision and tree to merge from.
593
598
'other_tree': self.other_tree,
594
599
'interesting_ids': self.interesting_ids,
595
600
'interesting_files': self.interesting_files,
596
'this_branch': self.this_branch,
601
'pp': self.pp, 'this_branch': self.this_branch,
597
602
'do_merge': False}
598
603
if self.merge_type.requires_base:
599
604
kwargs['base_tree'] = self.base_tree
617
622
if self._is_criss_cross and getattr(self.merge_type,
618
623
'supports_lca_trees', False):
619
624
kwargs['lca_trees'] = self._lca_trees
620
return self.merge_type(pb=None,
625
return self.merge_type(pb=self._pb,
621
626
change_reporter=self.change_reporter,
624
def _do_merge_to(self):
625
merge = self.make_merger()
629
def _do_merge_to(self, merge):
626
630
if self.other_branch is not None:
627
631
self.other_branch.update_references(self.this_branch)
642
646
sub_tree.branch.repository.revision_tree(base_revision)
643
647
sub_merge.base_rev_id = base_revision
644
648
sub_merge.do_merge()
647
650
def do_merge(self):
648
operation = OperationWithCleanups(self._do_merge_to)
649
651
self.this_tree.lock_tree_write()
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()
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()
658
669
if len(merge.cooked_conflicts) == 0:
659
670
if not self.ignore_zero and not trace.is_quiet():
660
671
trace.note("All changes applied successfully.")
696
707
def __init__(self, working_tree, this_tree, base_tree, other_tree,
697
708
interesting_ids=None, reprocess=False, show_base=False,
698
pb=None, pp=None, change_reporter=None,
709
pb=progress.DummyProgress(), pp=None, change_reporter=None,
699
710
interesting_files=None, do_merge=True,
700
711
cherrypick=False, lca_trees=None, this_branch=None):
701
712
"""Initialize the merger object and perform the merge.
711
722
:param: reprocess If True, perform conflict-reduction processing.
712
723
:param show_base: If True, show the base revision in text conflicts.
713
724
(incompatible with reprocess)
725
:param pb: A Progress bar
715
726
:param pp: A ProgressPhase object
716
727
:param change_reporter: An object that should report changes made
717
728
:param interesting_files: The tree-relative paths of files that should
744
755
# making sure we haven't missed any corner cases.
745
756
# if lca_trees is None:
746
757
# self._lca_trees = [self.base_tree]
747
760
self.change_reporter = change_reporter
748
761
self.cherrypick = cherrypick
763
self.pp = progress.ProgressPhase("Merge phase", 3, self.pb)
752
warnings.warn("pp argument to Merge3Merger is deprecated")
754
warnings.warn("pb argument to Merge3Merger is deprecated")
756
767
def do_merge(self):
757
operation = OperationWithCleanups(self._do_merge)
758
768
self.this_tree.lock_tree_write()
759
operation.add_cleanup(self.this_tree.unlock)
760
769
self.base_tree.lock_read()
761
operation.add_cleanup(self.base_tree.unlock)
762
770
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)
773
self.this_tree.add_conflicts(self.cooked_conflicts)
774
except errors.UnsupportedOperation:
772
self.tt = transform.TreeTransform(self.this_tree, self.pb)
775
self._compute_transform()
777
results = self.tt.apply(no_conflicts=True)
778
self.write_modified(results)
780
self.this_tree.add_conflicts(self.cooked_conflicts)
781
except errors.UnsupportedOperation:
786
self.other_tree.unlock()
787
self.base_tree.unlock()
788
self.this_tree.unlock()
777
791
def make_preview_transform(self):
778
operation = OperationWithCleanups(self._make_preview_transform)
779
792
self.base_tree.lock_read()
780
operation.add_cleanup(self.base_tree.unlock)
781
793
self.other_tree.lock_read()
782
operation.add_cleanup(self.other_tree.unlock)
783
return operation.run_simple()
785
def _make_preview_transform(self):
786
794
self.tt = transform.TransformPreview(self.this_tree)
787
self._compute_transform()
797
self._compute_transform()
800
self.other_tree.unlock()
801
self.base_tree.unlock()
790
805
def _compute_transform(self):