~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

remove all trailing whitespace from bzr source

Show diffs side-by-side

added added

removed removed

Lines of Context:
475
475
                    sub_tree.branch.repository.revision_tree(base_revision)
476
476
                sub_merge.base_rev_id = base_revision
477
477
                sub_merge.do_merge()
478
 
        
 
478
 
479
479
    def do_merge(self):
480
480
        self.this_tree.lock_tree_write()
481
481
        try:
532
532
    winner_idx = {"this": 2, "other": 1, "conflict": 1}
533
533
    supports_lca_trees = True
534
534
 
535
 
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
 
535
    def __init__(self, working_tree, this_tree, base_tree, other_tree,
536
536
                 interesting_ids=None, reprocess=False, show_base=False,
537
537
                 pb=DummyProgress(), pp=None, change_reporter=None,
538
538
                 interesting_files=None, do_merge=True,
876
876
        except NoSuchFile:
877
877
            self.tt.cancel_deletion(self.tt.root)
878
878
        if self.tt.final_file_id(self.tt.root) is None:
879
 
            self.tt.version_file(self.tt.tree_file_id(self.tt.root), 
 
879
            self.tt.version_file(self.tt.tree_file_id(self.tt.root),
880
880
                                 self.tt.root)
881
881
        other_root_file_id = self.other_tree.get_root_id()
882
882
        if other_root_file_id is None:
925
925
        if entry is None:
926
926
            return None
927
927
        return entry.name
928
 
    
 
928
 
929
929
    @staticmethod
930
930
    def contents_sha1(tree, file_id):
931
931
        """Determine the sha1 of the file contents (used as a key method)."""
1071
1071
            return
1072
1072
        if name_winner == "conflict":
1073
1073
            trans_id = self.tt.trans_id_file_id(file_id)
1074
 
            self._raw_conflicts.append(('name conflict', trans_id, 
 
1074
            self._raw_conflicts.append(('name conflict', trans_id,
1075
1075
                                        this_name, other_name))
1076
1076
        if parent_id_winner == "conflict":
1077
1077
            trans_id = self.tt.trans_id_file_id(file_id)
1078
 
            self._raw_conflicts.append(('parent conflict', trans_id, 
 
1078
            self._raw_conflicts.append(('parent conflict', trans_id,
1079
1079
                                        this_parent, other_parent))
1080
1080
        if other_name is None:
1081
 
            # it doesn't matter whether the result was 'other' or 
 
1081
            # it doesn't matter whether the result was 'other' or
1082
1082
            # 'conflict'-- if there's no 'other', we leave it alone.
1083
1083
            return
1084
1084
        # if we get here, name_winner and parent_winner are set to safe values.
1111
1111
                self.tt.unversion_file(trans_id)
1112
1112
                if file_id in self.this_tree:
1113
1113
                    self.tt.delete_contents(trans_id)
1114
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1114
            file_group = self._dump_conflicts(name, parent_id, file_id,
1115
1115
                                              set_version=True)
1116
1116
            self._raw_conflicts.append(('contents conflict', file_group))
1117
1117
 
1194
1194
 
1195
1195
        def iter_merge3(retval):
1196
1196
            retval["text_conflicts"] = False
1197
 
            for line in m3.merge_lines(name_a = "TREE", 
1198
 
                                       name_b = "MERGE-SOURCE", 
 
1197
            for line in m3.merge_lines(name_a = "TREE",
 
1198
                                       name_b = "MERGE-SOURCE",
1199
1199
                                       name_base = "BASE-REVISION",
1200
 
                                       start_marker=start_marker, 
 
1200
                                       start_marker=start_marker,
1201
1201
                                       base_marker=base_marker,
1202
1202
                                       reprocess=self.reprocess):
1203
1203
                if line.startswith(start_marker):
1212
1212
            self._raw_conflicts.append(('text conflict', trans_id))
1213
1213
            name = self.tt.final_name(trans_id)
1214
1214
            parent_id = self.tt.final_parent(trans_id)
1215
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1215
            file_group = self._dump_conflicts(name, parent_id, file_id,
1216
1216
                                              this_lines, base_lines,
1217
1217
                                              other_lines)
1218
1218
            file_group.append(trans_id)
1219
1219
 
1220
 
    def _dump_conflicts(self, name, parent_id, file_id, this_lines=None, 
 
1220
    def _dump_conflicts(self, name, parent_id, file_id, this_lines=None,
1221
1221
                        base_lines=None, other_lines=None, set_version=False,
1222
1222
                        no_base=False):
1223
1223
        """Emit conflict files.
1225
1225
        determined automatically.  If set_version is true, the .OTHER, .THIS
1226
1226
        or .BASE (in that order) will be created as versioned files.
1227
1227
        """
1228
 
        data = [('OTHER', self.other_tree, other_lines), 
 
1228
        data = [('OTHER', self.other_tree, other_lines),
1229
1229
                ('THIS', self.this_tree, this_lines)]
1230
1230
        if not no_base:
1231
1231
            data.append(('BASE', self.base_tree, base_lines))
1240
1240
                    self.tt.version_file(file_id, trans_id)
1241
1241
                    versioned = True
1242
1242
        return file_group
1243
 
           
 
1243
 
1244
1244
    def _conflict_file(self, name, parent_id, tree, file_id, suffix,
1245
1245
                       lines=None):
1246
1246
        """Emit a single conflict file."""
1304
1304
                conflict_args = conflict[2:]
1305
1305
                if trans_id not in name_conflicts:
1306
1306
                    name_conflicts[trans_id] = {}
1307
 
                unique_add(name_conflicts[trans_id], conflict_type, 
 
1307
                unique_add(name_conflicts[trans_id], conflict_type,
1308
1308
                           conflict_args)
1309
1309
            if conflict_type == 'contents conflict':
1310
1310
                for trans_id in conflict[1]:
1388
1388
        """
1389
1389
        lines, conflicts = self._merged_lines(file_id)
1390
1390
        lines = list(lines)
1391
 
        # Note we're checking whether the OUTPUT is binary in this case, 
 
1391
        # Note we're checking whether the OUTPUT is binary in this case,
1392
1392
        # because we don't want to get into weave merge guts.
1393
1393
        check_text_lines(lines)
1394
1394
        self.tt.create_file(lines, trans_id)
1396
1396
            self._raw_conflicts.append(('text conflict', trans_id))
1397
1397
            name = self.tt.final_name(trans_id)
1398
1398
            parent_id = self.tt.final_parent(trans_id)
1399
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1399
            file_group = self._dump_conflicts(name, parent_id, file_id,
1400
1400
                                              no_base=True)
1401
1401
            file_group.append(trans_id)
1402
1402
 
1479
1479
                this_tree=None,
1480
1480
                pb=DummyProgress(),
1481
1481
                change_reporter=None):
1482
 
    """Primary interface for merging. 
 
1482
    """Primary interface for merging.
1483
1483
 
1484
 
        typical use is probably 
 
1484
        typical use is probably
1485
1485
        'merge_inner(branch, branch.get_revision_tree(other_revision),
1486
1486
                     branch.get_revision_tree(base_revision))'
1487
1487
        """
1784
1784
 
1785
1785
    def _find_unique_parents(self, tip_keys, base_key):
1786
1786
        """Find ancestors of tip that aren't ancestors of base.
1787
 
        
 
1787
 
1788
1788
        :param tip_keys: Nodes that are interesting
1789
1789
        :param base_key: Cull all ancestors of this node
1790
1790
        :return: The parent map for all revisions between tip_keys and
1850
1850
    @staticmethod
1851
1851
    def _prune_tails(parent_map, child_map, tails_to_remove):
1852
1852
        """Remove tails from the parent map.
1853
 
        
 
1853
 
1854
1854
        This will remove the supplied revisions until no more children have 0
1855
1855
        parents.
1856
1856