~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Martin Pool
  • Date: 2008-06-11 02:36:40 UTC
  • mfrom: (3490 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3492.
  • Revision ID: mbp@sourcefrog.net-20080611023640-db0lqd75yueksdw7
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
                 this_tree=None, pb=DummyProgress(), change_reporter=None,
69
69
                 recurse='down', revision_graph=None):
70
70
        object.__init__(self)
71
 
        assert this_tree is not None, "this_tree is required"
72
71
        self.this_branch = this_branch
73
72
        self.this_basis = _mod_revision.ensure_null(
74
73
            this_branch.last_revision())
152
151
        base_revision_id, other_revision_id, verified =\
153
152
            mergeable.get_merge_request(tree.branch.repository)
154
153
        revision_graph = tree.branch.repository.get_graph()
155
 
        if (base_revision_id != _mod_revision.NULL_REVISION and
156
 
            revision_graph.is_ancestor(
157
 
            base_revision_id, tree.branch.last_revision())):
158
 
            base_revision_id = None
159
 
        else:
160
 
            warning('Performing cherrypick')
 
154
        if base_revision_id is not None:
 
155
            if (base_revision_id != _mod_revision.NULL_REVISION and
 
156
                revision_graph.is_ancestor(
 
157
                base_revision_id, tree.branch.last_revision())):
 
158
                base_revision_id = None
 
159
            else:
 
160
                warning('Performing cherrypick')
161
161
        merger = klass.from_revision_ids(pb, tree, other_revision_id,
162
162
                                         base_revision_id, revision_graph=
163
163
                                         revision_graph)
236
236
        self.ensure_revision_trees()
237
237
        def get_id(tree, file_id):
238
238
            revision_id = tree.inventory[file_id].revision
239
 
            assert revision_id is not None
240
239
            return revision_id
241
240
        if self.this_rev_id is None:
242
241
            if self.this_basis_tree.get_file_sha1(file_id) != \
490
489
            merge.
491
490
        """
492
491
        object.__init__(self)
493
 
        if interesting_files is not None:
494
 
            assert interesting_ids is None
 
492
        if interesting_files is not None and interesting_ids is not None:
 
493
            raise ValueError(
 
494
                'specify either interesting_ids or interesting_files')
495
495
        self.interesting_ids = interesting_ids
496
496
        self.interesting_files = interesting_files
497
497
        self.this_tree = working_tree
712
712
        if key_base == key_other:
713
713
            return "this"
714
714
        key_this = key(this_tree, file_id)
715
 
        if key_this not in (key_base, key_other):
 
715
        # "Ambiguous clean merge"
 
716
        if key_this == key_other:
 
717
            return "this"
 
718
        elif key_this == key_base:
 
719
            return "other"
 
720
        else:
716
721
            return "conflict"
717
 
        # "Ambiguous clean merge"
718
 
        elif key_this == key_other:
719
 
            return "this"
720
 
        else:
721
 
            assert key_this == key_base
722
 
            return "other"
723
722
 
724
723
    def merge_names(self, file_id):
725
724
        def get_entry(tree):
969
968
        if winner == "this":
970
969
            executability = this_executable
971
970
        else:
972
 
            assert winner == "other"
973
971
            if file_id in self.other_tree:
974
972
                executability = other_executable
975
973
            elif file_id in self.this_tree:
1017
1015
        for trans_id, conflicts in name_conflicts.iteritems():
1018
1016
            try:
1019
1017
                this_parent, other_parent = conflicts['parent conflict']
1020
 
                assert this_parent != other_parent
 
1018
                if this_parent == other_parent:
 
1019
                    raise AssertionError()
1021
1020
            except KeyError:
1022
1021
                this_parent = other_parent = \
1023
1022
                    self.tt.final_file_id(self.tt.final_parent(trans_id))
1024
1023
            try:
1025
1024
                this_name, other_name = conflicts['name conflict']
1026
 
                assert this_name != other_name
 
1025
                if this_name == other_name:
 
1026
                    raise AssertionError()
1027
1027
            except KeyError:
1028
1028
                this_name = other_name = self.tt.final_name(trans_id)
1029
1029
            other_path = fp.get_path(trans_id)
1182
1182
    merger.interesting_ids = interesting_ids
1183
1183
    merger.ignore_zero = ignore_zero
1184
1184
    if interesting_files:
1185
 
        assert not interesting_ids, ('Only supply interesting_ids'
1186
 
                                     ' or interesting_files')
 
1185
        if interesting_ids:
 
1186
            raise ValueError('Only supply interesting_ids'
 
1187
                             ' or interesting_files')
1187
1188
        merger.interesting_files = interesting_files
1188
1189
    merger.show_base = show_base
1189
1190
    merger.reprocess = reprocess
1231
1232
            yield status_a(revision, text)
1232
1233
        for revision, text in annotated_b[b_cur:bi]:
1233
1234
            yield status_b(revision, text)
1234
 
 
1235
1235
        # and now the matched section
1236
1236
        a_cur = ai + l
1237
1237
        b_cur = bi + l
1238
 
        for text_a, text_b in zip(plain_a[ai:a_cur], plain_b[bi:b_cur]):
1239
 
            assert text_a == text_b
 
1238
        for text_a in plain_a[ai:a_cur]:
1240
1239
            yield "unchanged", text_a
1241
1240
 
1242
1241
 
1435
1434
        _PlanMergeBase.__init__(self, a_rev, b_rev, vf)
1436
1435
        self.lcas = graph.find_lca(a_rev, b_rev)
1437
1436
        for lca in self.lcas:
1438
 
            lca_lines = self.vf.get_lines(lca)
 
1437
            if _mod_revision.is_null(lca):
 
1438
                lca_lines = []
 
1439
            else:
 
1440
                lca_lines = self.vf.get_lines(lca)
1439
1441
            matcher = patiencediff.PatienceSequenceMatcher(None, self.lines_a,
1440
1442
                                                           lca_lines)
1441
1443
            blocks = list(matcher.get_matching_blocks())