~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-28 10:06:39 UTC
  • mfrom: (6437.40.2 rmbranch-colo)
  • mto: This revision was merged to the branch mainline in revision 6482.
  • Revision ID: jelmer@samba.org-20120228100639-p5gndu91wuqwugti
Merge rmbranch-colo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
940
940
        result = []
941
941
        walker = _mod_tree.MultiWalker(self.other_tree, self._lca_trees)
942
942
 
943
 
        base_inventory = self.base_tree.inventory
944
 
        this_inventory = self.this_tree.inventory
 
943
        base_inventory = self.base_tree.root_inventory
 
944
        this_inventory = self.this_tree.root_inventory
945
945
        for path, file_id, other_ie, lca_values in walker.iter_all():
946
946
            # Is this modified at all from any of the other trees?
947
947
            if other_ie is None:
1091
1091
        other_root = self.tt.trans_id_file_id(other_root_file_id)
1092
1092
        if other_root == self.tt.root:
1093
1093
            return
1094
 
        if self.this_tree.inventory.has_id(
1095
 
            self.other_tree.inventory.root.file_id):
 
1094
        if self.this_tree.has_id(
 
1095
            self.other_tree.get_root_id()):
1096
1096
            # the other tree's root is a non-root in the current tree (as
1097
1097
            # when a previously unrelated branch is merged into another)
1098
1098
            return
1102
1102
            # other_root doesn't have a physical representation. We still need
1103
1103
            # to move any references to the actual root of the tree.
1104
1104
            other_root_is_present = False
1105
 
        # 'other_tree.inventory.root' is not present in this tree. We are
 
1105
        # the other tree root is not present in this tree. We are
1106
1106
        # calling adjust_path for children which *want* to be present with a
1107
1107
        # correct place to go.
1108
 
        for _, child in self.other_tree.inventory.root.children.iteritems():
1109
 
            trans_id = self.tt.trans_id_file_id(child.file_id)
 
1108
        for child_id in self.other_tree.iter_children(
 
1109
                self.other_tree.get_root_id()):
 
1110
            trans_id = self.tt.trans_id_file_id(child_id)
1110
1111
            if not other_root_is_present:
1111
1112
                if self.tt.final_kind(trans_id) is not None:
1112
1113
                    # The item exist in the final tree and has a defined place
1260
1261
 
1261
1262
    def merge_names(self, file_id):
1262
1263
        def get_entry(tree):
1263
 
            if tree.has_id(file_id):
1264
 
                return tree.inventory[file_id]
1265
 
            else:
 
1264
            try:
 
1265
                return tree.root_inventory[file_id]
 
1266
            except errors.NoSuchId:
1266
1267
                return None
1267
1268
        this_entry = get_entry(self.this_tree)
1268
1269
        other_entry = get_entry(self.other_tree)
1940
1941
 
1941
1942
    def _entries_to_incorporate(self):
1942
1943
        """Yields pairs of (inventory_entry, new_parent)."""
1943
 
        other_inv = self.other_tree.inventory
 
1944
        other_inv = self.other_tree.root_inventory
1944
1945
        subdir_id = other_inv.path2id(self._source_subpath)
1945
1946
        if subdir_id is None:
1946
1947
            # XXX: The error would be clearer if it gave the URL of the source
1948
1949
            raise PathNotInTree(self._source_subpath, "Source tree")
1949
1950
        subdir = other_inv[subdir_id]
1950
1951
        parent_in_target = osutils.dirname(self._target_subdir)
1951
 
        target_id = self.this_tree.inventory.path2id(parent_in_target)
 
1952
        target_id = self.this_tree.path2id(parent_in_target)
1952
1953
        if target_id is None:
1953
1954
            raise PathNotInTree(self._target_subdir, "Target tree")
1954
1955
        name_in_target = osutils.basename(self._target_subdir)
1955
1956
        merge_into_root = subdir.copy()
1956
1957
        merge_into_root.name = name_in_target
1957
 
        if self.this_tree.inventory.has_id(merge_into_root.file_id):
 
1958
        if self.this_tree.has_id(merge_into_root.file_id):
1958
1959
            # Give the root a new file-id.
1959
1960
            # This can happen fairly easily if the directory we are
1960
1961
            # incorporating is the root, and both trees have 'TREE_ROOT' as