~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

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.root_inventory
944
 
        this_inventory = self.this_tree.root_inventory
 
943
        base_inventory = self.base_tree.inventory
 
944
        this_inventory = self.this_tree.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:
1078
1078
                          ))
1079
1079
        return result
1080
1080
 
 
1081
    @deprecated_method(deprecated_in((2, 4, 0)))
 
1082
    def fix_root(self):
 
1083
        if self.tt.final_kind(self.tt.root) is None:
 
1084
            self.tt.cancel_deletion(self.tt.root)
 
1085
        if self.tt.final_file_id(self.tt.root) is None:
 
1086
            self.tt.version_file(self.tt.tree_file_id(self.tt.root),
 
1087
                                 self.tt.root)
 
1088
        other_root_file_id = self.other_tree.get_root_id()
 
1089
        if other_root_file_id is None:
 
1090
            return
 
1091
        other_root = self.tt.trans_id_file_id(other_root_file_id)
 
1092
        if other_root == self.tt.root:
 
1093
            return
 
1094
        if self.this_tree.inventory.has_id(
 
1095
            self.other_tree.inventory.root.file_id):
 
1096
            # the other tree's root is a non-root in the current tree (as
 
1097
            # when a previously unrelated branch is merged into another)
 
1098
            return
 
1099
        if self.tt.final_kind(other_root) is not None:
 
1100
            other_root_is_present = True
 
1101
        else:
 
1102
            # other_root doesn't have a physical representation. We still need
 
1103
            # to move any references to the actual root of the tree.
 
1104
            other_root_is_present = False
 
1105
        # 'other_tree.inventory.root' is not present in this tree. We are
 
1106
        # calling adjust_path for children which *want* to be present with a
 
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)
 
1110
            if not other_root_is_present:
 
1111
                if self.tt.final_kind(trans_id) is not None:
 
1112
                    # The item exist in the final tree and has a defined place
 
1113
                    # to go already.
 
1114
                    continue
 
1115
            # Move the item into the root
 
1116
            try:
 
1117
                final_name = self.tt.final_name(trans_id)
 
1118
            except errors.NoFinalPath:
 
1119
                # This file is not present anymore, ignore it.
 
1120
                continue
 
1121
            self.tt.adjust_path(final_name, self.tt.root, trans_id)
 
1122
        if other_root_is_present:
 
1123
            self.tt.cancel_creation(other_root)
 
1124
            self.tt.cancel_versioning(other_root)
 
1125
 
1081
1126
    def write_modified(self, results):
1082
1127
        modified_hashes = {}
1083
1128
        for path in results.modified_paths:
1193
1238
        # At this point, the lcas disagree, and the tip disagree
1194
1239
        return 'conflict'
1195
1240
 
 
1241
    @staticmethod
 
1242
    @deprecated_method(deprecated_in((2, 2, 0)))
 
1243
    def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
 
1244
        """Do a three-way test on a scalar.
 
1245
        Return "this", "other" or "conflict", depending whether a value wins.
 
1246
        """
 
1247
        key_base = key(base_tree, file_id)
 
1248
        key_other = key(other_tree, file_id)
 
1249
        #if base == other, either they all agree, or only THIS has changed.
 
1250
        if key_base == key_other:
 
1251
            return "this"
 
1252
        key_this = key(this_tree, file_id)
 
1253
        # "Ambiguous clean merge"
 
1254
        if key_this == key_other:
 
1255
            return "this"
 
1256
        elif key_this == key_base:
 
1257
            return "other"
 
1258
        else:
 
1259
            return "conflict"
 
1260
 
1196
1261
    def merge_names(self, file_id):
1197
1262
        def get_entry(tree):
1198
 
            try:
1199
 
                return tree.root_inventory[file_id]
1200
 
            except errors.NoSuchId:
 
1263
            if tree.has_id(file_id):
 
1264
                return tree.inventory[file_id]
 
1265
            else:
1201
1266
                return None
1202
1267
        this_entry = get_entry(self.this_tree)
1203
1268
        other_entry = get_entry(self.other_tree)
1875
1940
 
1876
1941
    def _entries_to_incorporate(self):
1877
1942
        """Yields pairs of (inventory_entry, new_parent)."""
1878
 
        other_inv = self.other_tree.root_inventory
 
1943
        other_inv = self.other_tree.inventory
1879
1944
        subdir_id = other_inv.path2id(self._source_subpath)
1880
1945
        if subdir_id is None:
1881
1946
            # XXX: The error would be clearer if it gave the URL of the source
1883
1948
            raise PathNotInTree(self._source_subpath, "Source tree")
1884
1949
        subdir = other_inv[subdir_id]
1885
1950
        parent_in_target = osutils.dirname(self._target_subdir)
1886
 
        target_id = self.this_tree.path2id(parent_in_target)
 
1951
        target_id = self.this_tree.inventory.path2id(parent_in_target)
1887
1952
        if target_id is None:
1888
1953
            raise PathNotInTree(self._target_subdir, "Target tree")
1889
1954
        name_in_target = osutils.basename(self._target_subdir)
1890
1955
        merge_into_root = subdir.copy()
1891
1956
        merge_into_root.name = name_in_target
1892
 
        if self.this_tree.has_id(merge_into_root.file_id):
 
1957
        if self.this_tree.inventory.has_id(merge_into_root.file_id):
1893
1958
            # Give the root a new file-id.
1894
1959
            # This can happen fairly easily if the directory we are
1895
1960
            # incorporating is the root, and both trees have 'TREE_ROOT' as