/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/merge.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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:
453
 
            try:
454
 
                tree = self.revision_tree(revision_id)
455
 
            except errors.NoSuchRevision:
456
 
                tree = None
457
 
            else:
458
 
                tree.lock_read()
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:
 
452
                try:
 
453
                    tree = self.revision_tree(revision_id)
 
454
                except errors.NoSuchRevision:
 
455
                    tree = None
 
456
                else:
 
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)
462
460
 
463
461
    def set_other(self, other_revision, possible_transports=None):
464
462
        """Set the revision and tree to merge from.
656
654
        return merge
657
655
 
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."))
759
754
            self.do_merge()
760
755
 
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)
771
 
        operation.run()
772
 
 
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)
779
 
        try:
780
 
            self.working_tree.add_conflicts(self.cooked_conflicts)
781
 
        except errors.UnsupportedOperation:
782
 
            pass
 
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)
 
767
            try:
 
768
                self.working_tree.add_conflicts(self.cooked_conflicts)
 
769
            except errors.UnsupportedOperation:
 
770
                pass
783
771
 
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>'
1565
1553
                else:
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
1569
1557
                        # exception