~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-15 18:09:55 UTC
  • mfrom: (5159.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100415180955-v9jh960r07pva92c
(vila) Merge 2.1 into bzr.dev including fixes for #262450, #373898,
        #498409

Show diffs side-by-side

added added

removed removed

Lines of Context:
1042
1042
        other_root = self.tt.trans_id_file_id(other_root_file_id)
1043
1043
        if other_root == self.tt.root:
1044
1044
            return
 
1045
        if self.other_tree.inventory.root.file_id in self.this_tree.inventory:
 
1046
            # the other tree's root is a non-root in the current tree (as when
 
1047
            # a previously unrelated branch is merged into another)
 
1048
            return
1045
1049
        try:
1046
1050
            self.tt.final_kind(other_root)
 
1051
            other_root_is_present = True
1047
1052
        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():
 
1053
            # other_root doesn't have a physical representation. We still need
 
1054
            # to move any references to the actual root of the tree.
 
1055
            other_root_is_present = False
 
1056
        # 'other_tree.inventory.root' is not present in this tree. We are
 
1057
        # calling adjust_path for children which *want* to be present with a
 
1058
        # correct place to go.
 
1059
        for thing, child in self.other_tree.inventory.root.children.iteritems():
1058
1060
            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)
 
1061
            if not other_root_is_present:
 
1062
                # FIXME: Make final_kind returns None instead of raising
 
1063
                # NoSuchFile to avoid the ugly construct below -- vila 20100402
 
1064
                try:
 
1065
                    self.tt.final_kind(trans_id)
 
1066
                    # The item exist in the final tree and has a defined place
 
1067
                    # to go already.
 
1068
                    continue
 
1069
                except errors.NoSuchFile, e:
 
1070
                    pass
 
1071
            # Move the item into the root
 
1072
            self.tt.adjust_path(self.tt.final_name(trans_id),
 
1073
                                self.tt.root, trans_id)
 
1074
        if other_root_is_present:
 
1075
            self.tt.cancel_creation(other_root)
 
1076
            self.tt.cancel_versioning(other_root)
1060
1077
 
1061
1078
    def write_modified(self, results):
1062
1079
        modified_hashes = {}