~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-23 15:29:35 UTC
  • mfrom: (3943.7.7 bzr.code_style_cleanup)
  • mto: This revision was merged to the branch mainline in revision 4033.
  • Revision ID: john@arbash-meinel.com-20090223152935-oel9m92mwcc6nb4h
Merge the removal of all trailing whitespace, and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
477
477
                    sub_tree.branch.repository.revision_tree(base_revision)
478
478
                sub_merge.base_rev_id = base_revision
479
479
                sub_merge.do_merge()
480
 
        
 
480
 
481
481
    def do_merge(self):
482
482
        self.this_tree.lock_tree_write()
483
483
        try:
534
534
    winner_idx = {"this": 2, "other": 1, "conflict": 1}
535
535
    supports_lca_trees = True
536
536
 
537
 
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
 
537
    def __init__(self, working_tree, this_tree, base_tree, other_tree,
538
538
                 interesting_ids=None, reprocess=False, show_base=False,
539
539
                 pb=DummyProgress(), pp=None, change_reporter=None,
540
540
                 interesting_files=None, do_merge=True,
874
874
        except NoSuchFile:
875
875
            self.tt.cancel_deletion(self.tt.root)
876
876
        if self.tt.final_file_id(self.tt.root) is None:
877
 
            self.tt.version_file(self.tt.tree_file_id(self.tt.root), 
 
877
            self.tt.version_file(self.tt.tree_file_id(self.tt.root),
878
878
                                 self.tt.root)
879
879
        other_root_file_id = self.other_tree.get_root_id()
880
880
        if other_root_file_id is None:
923
923
        if entry is None:
924
924
            return None
925
925
        return entry.name
926
 
    
 
926
 
927
927
    @staticmethod
928
928
    def contents_sha1(tree, file_id):
929
929
        """Determine the sha1 of the file contents (used as a key method)."""
1069
1069
            return
1070
1070
        if name_winner == "conflict":
1071
1071
            trans_id = self.tt.trans_id_file_id(file_id)
1072
 
            self._raw_conflicts.append(('name conflict', trans_id, 
 
1072
            self._raw_conflicts.append(('name conflict', trans_id,
1073
1073
                                        this_name, other_name))
1074
1074
        if parent_id_winner == "conflict":
1075
1075
            trans_id = self.tt.trans_id_file_id(file_id)
1076
 
            self._raw_conflicts.append(('parent conflict', trans_id, 
 
1076
            self._raw_conflicts.append(('parent conflict', trans_id,
1077
1077
                                        this_parent, other_parent))
1078
1078
        if other_name is None:
1079
 
            # it doesn't matter whether the result was 'other' or 
 
1079
            # it doesn't matter whether the result was 'other' or
1080
1080
            # 'conflict'-- if there's no 'other', we leave it alone.
1081
1081
            return
1082
1082
        # if we get here, name_winner and parent_winner are set to safe values.
1109
1109
                self.tt.unversion_file(trans_id)
1110
1110
                if file_id in self.this_tree:
1111
1111
                    self.tt.delete_contents(trans_id)
1112
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1112
            file_group = self._dump_conflicts(name, parent_id, file_id,
1113
1113
                                              set_version=True)
1114
1114
            self._raw_conflicts.append(('contents conflict', file_group))
1115
1115
 
1202
1202
 
1203
1203
        def iter_merge3(retval):
1204
1204
            retval["text_conflicts"] = False
1205
 
            for line in m3.merge_lines(name_a = "TREE", 
1206
 
                                       name_b = "MERGE-SOURCE", 
 
1205
            for line in m3.merge_lines(name_a = "TREE",
 
1206
                                       name_b = "MERGE-SOURCE",
1207
1207
                                       name_base = "BASE-REVISION",
1208
 
                                       start_marker=start_marker, 
 
1208
                                       start_marker=start_marker,
1209
1209
                                       base_marker=base_marker,
1210
1210
                                       reprocess=self.reprocess):
1211
1211
                if line.startswith(start_marker):
1220
1220
            self._raw_conflicts.append(('text conflict', trans_id))
1221
1221
            name = self.tt.final_name(trans_id)
1222
1222
            parent_id = self.tt.final_parent(trans_id)
1223
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1223
            file_group = self._dump_conflicts(name, parent_id, file_id,
1224
1224
                                              this_lines, base_lines,
1225
1225
                                              other_lines)
1226
1226
            file_group.append(trans_id)
1227
1227
 
1228
 
    def _dump_conflicts(self, name, parent_id, file_id, this_lines=None, 
 
1228
    def _dump_conflicts(self, name, parent_id, file_id, this_lines=None,
1229
1229
                        base_lines=None, other_lines=None, set_version=False,
1230
1230
                        no_base=False):
1231
1231
        """Emit conflict files.
1233
1233
        determined automatically.  If set_version is true, the .OTHER, .THIS
1234
1234
        or .BASE (in that order) will be created as versioned files.
1235
1235
        """
1236
 
        data = [('OTHER', self.other_tree, other_lines), 
 
1236
        data = [('OTHER', self.other_tree, other_lines),
1237
1237
                ('THIS', self.this_tree, this_lines)]
1238
1238
        if not no_base:
1239
1239
            data.append(('BASE', self.base_tree, base_lines))
1248
1248
                    self.tt.version_file(file_id, trans_id)
1249
1249
                    versioned = True
1250
1250
        return file_group
1251
 
           
 
1251
 
1252
1252
    def _conflict_file(self, name, parent_id, tree, file_id, suffix,
1253
1253
                       lines=None):
1254
1254
        """Emit a single conflict file."""
1312
1312
                conflict_args = conflict[2:]
1313
1313
                if trans_id not in name_conflicts:
1314
1314
                    name_conflicts[trans_id] = {}
1315
 
                unique_add(name_conflicts[trans_id], conflict_type, 
 
1315
                unique_add(name_conflicts[trans_id], conflict_type,
1316
1316
                           conflict_args)
1317
1317
            if conflict_type == 'contents conflict':
1318
1318
                for trans_id in conflict[1]:
1396
1396
        """
1397
1397
        lines, conflicts = self._merged_lines(file_id)
1398
1398
        lines = list(lines)
1399
 
        # Note we're checking whether the OUTPUT is binary in this case, 
 
1399
        # Note we're checking whether the OUTPUT is binary in this case,
1400
1400
        # because we don't want to get into weave merge guts.
1401
1401
        check_text_lines(lines)
1402
1402
        self.tt.create_file(lines, trans_id)
1404
1404
            self._raw_conflicts.append(('text conflict', trans_id))
1405
1405
            name = self.tt.final_name(trans_id)
1406
1406
            parent_id = self.tt.final_parent(trans_id)
1407
 
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1407
            file_group = self._dump_conflicts(name, parent_id, file_id,
1408
1408
                                              no_base=True)
1409
1409
            file_group.append(trans_id)
1410
1410
 
1487
1487
                this_tree=None,
1488
1488
                pb=DummyProgress(),
1489
1489
                change_reporter=None):
1490
 
    """Primary interface for merging. 
 
1490
    """Primary interface for merging.
1491
1491
 
1492
 
        typical use is probably 
 
1492
        typical use is probably
1493
1493
        'merge_inner(branch, branch.get_revision_tree(other_revision),
1494
1494
                     branch.get_revision_tree(base_revision))'
1495
1495
        """
1792
1792
 
1793
1793
    def _find_unique_parents(self, tip_keys, base_key):
1794
1794
        """Find ancestors of tip that aren't ancestors of base.
1795
 
        
 
1795
 
1796
1796
        :param tip_keys: Nodes that are interesting
1797
1797
        :param base_key: Cull all ancestors of this node
1798
1798
        :return: The parent map for all revisions between tip_keys and
1858
1858
    @staticmethod
1859
1859
    def _prune_tails(parent_map, child_map, tails_to_remove):
1860
1860
        """Remove tails from the parent map.
1861
 
        
 
1861
 
1862
1862
        This will remove the supplied revisions until no more children have 0
1863
1863
        parents.
1864
1864