/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 bzrlib/merge.py

  • Committer: Martin Pool
  • Date: 2010-04-28 07:03:38 UTC
  • mfrom: (5188 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@sourcefrog.net-20100428070338-2af8y3takgfkrkyp
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
704
704
        :param this_tree: The local tree in the merge operation
705
705
        :param base_tree: The common tree in the merge operation
706
706
        :param other_tree: The other tree to merge changes from
707
 
        :param this_branch: The branch associated with this_tree
 
707
        :param this_branch: The branch associated with this_tree.  Defaults to
 
708
            this_tree.branch if not supplied.
708
709
        :param interesting_ids: The file_ids of files that should be
709
710
            participate in the merge.  May not be combined with
710
711
            interesting_files.
728
729
        if interesting_files is not None and interesting_ids is not None:
729
730
            raise ValueError(
730
731
                'specify either interesting_ids or interesting_files')
 
732
        if this_branch is None:
 
733
            this_branch = this_tree.branch
731
734
        self.interesting_ids = interesting_ids
732
735
        self.interesting_files = interesting_files
733
736
        self.this_tree = working_tree
1042
1045
        other_root = self.tt.trans_id_file_id(other_root_file_id)
1043
1046
        if other_root == self.tt.root:
1044
1047
            return
 
1048
        if self.other_tree.inventory.root.file_id in self.this_tree.inventory:
 
1049
            # the other tree's root is a non-root in the current tree (as when
 
1050
            # a previously unrelated branch is merged into another)
 
1051
            return
1045
1052
        try:
1046
1053
            self.tt.final_kind(other_root)
 
1054
            other_root_is_present = True
1047
1055
        except errors.NoSuchFile:
1048
 
            return
1049
 
        if self.this_tree.has_id(self.other_tree.inventory.root.file_id):
1050
 
            # the other tree's root is a non-root in the current tree
1051
 
            return
1052
 
        self.reparent_children(self.other_tree.inventory.root, self.tt.root)
1053
 
        self.tt.cancel_creation(other_root)
1054
 
        self.tt.cancel_versioning(other_root)
1055
 
 
1056
 
    def reparent_children(self, ie, target):
1057
 
        for thing, child in ie.children.iteritems():
 
1056
            # other_root doesn't have a physical representation. We still need
 
1057
            # to move any references to the actual root of the tree.
 
1058
            other_root_is_present = False
 
1059
        # 'other_tree.inventory.root' is not present in this tree. We are
 
1060
        # calling adjust_path for children which *want* to be present with a
 
1061
        # correct place to go.
 
1062
        for thing, child in self.other_tree.inventory.root.children.iteritems():
1058
1063
            trans_id = self.tt.trans_id_file_id(child.file_id)
1059
 
            self.tt.adjust_path(self.tt.final_name(trans_id), target, trans_id)
 
1064
            if not other_root_is_present:
 
1065
                # FIXME: Make final_kind returns None instead of raising
 
1066
                # NoSuchFile to avoid the ugly construct below -- vila 20100402
 
1067
                try:
 
1068
                    self.tt.final_kind(trans_id)
 
1069
                    # The item exist in the final tree and has a defined place
 
1070
                    # to go already.
 
1071
                    continue
 
1072
                except errors.NoSuchFile, e:
 
1073
                    pass
 
1074
            # Move the item into the root
 
1075
            self.tt.adjust_path(self.tt.final_name(trans_id),
 
1076
                                self.tt.root, trans_id)
 
1077
        if other_root_is_present:
 
1078
            self.tt.cancel_creation(other_root)
 
1079
            self.tt.cancel_versioning(other_root)
1060
1080
 
1061
1081
    def write_modified(self, results):
1062
1082
        modified_hashes = {}