~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

merge fix for bug #177643

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
            tree.branch.repository.get_graph().is_ancestor(
120
120
            base_revision_id, tree.branch.last_revision())):
121
121
            base_revision_id = None
 
122
        else:
 
123
            warning('Performing cherrypick')
122
124
        merger = klass.from_revision_ids(pb, tree, other_revision_id,
123
125
                                         base_revision_id)
124
126
        return merger, verified
368
370
        elif self.show_base:
369
371
            raise BzrError("Showing base is not supported for this"
370
372
                                  " merge type. %s" % self.merge_type)
 
373
        if (not getattr(self.merge_type, 'supports_reverse_cherrypick', True)
 
374
            and not self.base_is_other_ancestor):
 
375
            raise errors.CannotReverseCherrypick()
 
376
        if self.merge_type.history_based:
 
377
            kwargs['cherrypick'] = (not self.base_is_ancestor or
 
378
                                    not self.base_is_other_ancestor)
371
379
        self.this_tree.lock_tree_write()
372
380
        if self.base_tree is not None:
373
381
            self.base_tree.lock_read()
415
423
    supports_reprocess = True
416
424
    supports_show_base = True
417
425
    history_based = False
 
426
    supports_reverse_cherrypick = True
418
427
    winner_idx = {"this": 2, "other": 1, "conflict": 1}
419
428
 
420
429
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
977
986
    """Three-way tree merger, text weave merger."""
978
987
    supports_reprocess = True
979
988
    supports_show_base = False
 
989
    supports_reverse_cherrypick = False
 
990
    history_based = True
980
991
 
981
992
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
982
993
                 interesting_ids=None, pb=DummyProgress(), pp=None,
983
994
                 reprocess=False, change_reporter=None,
984
 
                 interesting_files=None):
 
995
                 interesting_files=None, cherrypick=False):
 
996
        self.cherrypick = cherrypick
985
997
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
986
998
                                          base_tree, other_tree, 
987
999
                                          interesting_ids=interesting_ids, 
993
1005
        There is no distinction between lines that are meant to contain <<<<<<<
994
1006
        and conflicts.
995
1007
        """
996
 
        plan = self.this_tree.plan_file_merge(file_id, self.other_tree)
 
1008
        if self.cherrypick:
 
1009
            base = self.base_tree
 
1010
        else:
 
1011
            base = None
 
1012
        plan = self.this_tree.plan_file_merge(file_id, self.other_tree,
 
1013
                                              base=base)
997
1014
        if 'merge' in debug.debug_flags:
998
1015
            plan = list(plan)
999
1016
            trans_id = self.tt.trans_id_file_id(file_id)
1263
1280
            else:
1264
1281
                new.intersection_update(result)
1265
1282
        return new
 
1283
 
 
1284
    @staticmethod
 
1285
    def _subtract_plans(old_plan, new_plan):
 
1286
        matcher = patiencediff.PatienceSequenceMatcher(None, old_plan,
 
1287
                                                       new_plan)
 
1288
        last_j = 0
 
1289
        for i, j, n in matcher.get_matching_blocks():
 
1290
            for jj in range(last_j, j):
 
1291
                yield new_plan[jj]
 
1292
            for jj in range(j, j+n):
 
1293
                plan_line = new_plan[jj]
 
1294
                if plan_line[0] == 'new-b':
 
1295
                    pass
 
1296
                elif plan_line[0] == 'killed-b':
 
1297
                    yield 'unchanged', plan_line[1]
 
1298
                else:
 
1299
                    yield plan_line
 
1300
            last_j = j + n