~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Got merge with rename working

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
        unique_add(self._new_id, trans_id, file_id)
214
214
        unique_add(self._r_new_id, file_id, trans_id)
215
215
 
 
216
    def cancel_versioning(self, trans_id):
 
217
        """Undo a previous versioning of a file"""
 
218
        file_id = self._new_id[trans_id]
 
219
        del self._new_id[trans_id]
 
220
        del self._r_new_id[file_id]
 
221
 
216
222
    def new_paths(self):
217
223
        """Determine the paths of all new and changed files"""
218
224
        new_ids = set()
942
948
        self.tt = TreeTransform(working_tree)
943
949
        try:
944
950
            for file_id in all_ids:
 
951
                self.merge_names(file_id)
945
952
                file_status = self.merge_contents(file_id)
946
953
                self.merge_executable(file_id, file_status)
947
954
                
955
962
       
956
963
    @staticmethod
957
964
    def parent(entry, file_id):
958
 
        return entry.parent
 
965
        if entry is None:
 
966
            return None
 
967
        return entry.parent_id
959
968
 
960
969
    @staticmethod
961
970
    def name(entry, file_id):
 
971
        if entry is None:
 
972
            return None
962
973
        return entry.name
963
974
    
964
975
    @staticmethod
999
1010
            assert key_this == key_base
1000
1011
            return "other"
1001
1012
 
 
1013
    def merge_names(self, file_id):
 
1014
        def get_entry(tree):
 
1015
            if file_id in tree.inventory:
 
1016
                return tree.inventory[file_id]
 
1017
            else:
 
1018
                return None
 
1019
        this_entry = get_entry(self.this_tree)
 
1020
        other_entry = get_entry(self.other_tree)
 
1021
        base_entry = get_entry(self.base_tree)
 
1022
        name_winner = self.scalar_three_way(this_entry, base_entry, 
 
1023
                                            other_entry, file_id, self.name)
 
1024
        parent_id_winner = self.scalar_three_way(this_entry, base_entry, 
 
1025
                                                 other_entry, file_id, 
 
1026
                                                 self.parent)
 
1027
        if this_entry is None:
 
1028
            if name_winner == "this":
 
1029
                name_winner = "other"
 
1030
            if parent_id_winner == "this":
 
1031
                parent_id_winner = "other"
 
1032
        if name_winner == "this" and parent_id_winner == "this":
 
1033
            return
 
1034
        if other_entry is None:
 
1035
            # it doesn't matter whether the result was 'other' or 
 
1036
            # 'conflict'-- if there's no 'other', we leave it alone.
 
1037
            return
 
1038
        # if we get here, name_winner and parent_winner are set to safe values.
 
1039
        winner_entry = {"this": this_entry, "other": other_entry, 
 
1040
                        "conflict": other_entry}
 
1041
        trans_id = self.tt.get_trans_id(file_id)
 
1042
        parent_id = winner_entry[parent_id_winner].parent_id
 
1043
        parent_trans_id = self.tt.get_trans_id(parent_id)
 
1044
        self.tt.adjust_path(winner_entry[name_winner].name, parent_trans_id,
 
1045
                            trans_id)
 
1046
 
 
1047
 
1002
1048
    def merge_contents(self, file_id):
1003
1049
        def contents_pair(tree):
1004
1050
            if file_id not in tree:
1040
1086
                self.text_merge(file_id, trans_id)
1041
1087
                return "modified"
1042
1088
            else:
1043
 
                trans_id = self.tt.get_id_tree(file_id)
 
1089
                trans_id = self.tt.get_trans_id(file_id)
1044
1090
                name = self.tt.final_name(trans_id)
1045
1091
                parent_id = self.tt.final_parent(trans_id)
1046
1092
                if file_id in self.this_tree.inventory:
1047
1093
                    self.tt.unversion_file(trans_id)
1048
1094
                    self.tt.delete_contents(trans_id)
 
1095
                else:
 
1096
                    self.tt.cancel_versioning(trans_id)
1049
1097
                file_group = self._dump_conflicts(name, parent_id, file_id, 
1050
1098
                                                  set_version=True)
1051
1099