~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-20 04:20:19 UTC
  • mfrom: (3062.2.13 fast-plan-merge2)
  • Revision ID: pqm@pqm.ubuntu.com-20071220042019-wsij5vgvhgw4qhdt
Annotate merge can do cherrypicks (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
370
370
        elif self.show_base:
371
371
            raise BzrError("Showing base is not supported for this"
372
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)
373
379
        self.this_tree.lock_tree_write()
374
380
        if self.base_tree is not None:
375
381
            self.base_tree.lock_read()
417
423
    supports_reprocess = True
418
424
    supports_show_base = True
419
425
    history_based = False
 
426
    supports_reverse_cherrypick = True
420
427
    winner_idx = {"this": 2, "other": 1, "conflict": 1}
421
428
 
422
429
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
979
986
    """Three-way tree merger, text weave merger."""
980
987
    supports_reprocess = True
981
988
    supports_show_base = False
 
989
    supports_reverse_cherrypick = False
 
990
    history_based = True
982
991
 
983
992
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
984
993
                 interesting_ids=None, pb=DummyProgress(), pp=None,
985
994
                 reprocess=False, change_reporter=None,
986
 
                 interesting_files=None):
 
995
                 interesting_files=None, cherrypick=False):
 
996
        self.cherrypick = cherrypick
987
997
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
988
998
                                          base_tree, other_tree, 
989
999
                                          interesting_ids=interesting_ids, 
995
1005
        There is no distinction between lines that are meant to contain <<<<<<<
996
1006
        and conflicts.
997
1007
        """
998
 
        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)
999
1014
        if 'merge' in debug.debug_flags:
1000
1015
            plan = list(plan)
1001
1016
            trans_id = self.tt.trans_id_file_id(file_id)
1265
1280
            else:
1266
1281
                new.intersection_update(result)
1267
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