~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2007-12-03 15:15:36 UTC
  • mto: This revision was merged to the branch mainline in revision 3133.
  • Revision ID: abentley@panoramicfeedback.com-20071203151536-b34fe60wl3nr9eln
Add support for plan-merge with a base

Show diffs side-by-side

added added

removed removed

Lines of Context:
1158
1158
        self._last_lines = None
1159
1159
        self._last_lines_revision_id = None
1160
1160
 
 
1161
    @classmethod
 
1162
    def plan_merge_with_base(klass, this, base, other, vf):
 
1163
        old_plan = list(klass(this, base, vf).plan_merge())
 
1164
        new_plan = list(klass(this, other, vf).plan_merge())
 
1165
        return klass._subtract_plans(old_plan, new_plan)
 
1166
 
1161
1167
    def plan_merge(self):
1162
1168
        """Generate a 'plan' for merging the two revisions.
1163
1169
 
1252
1258
            else:
1253
1259
                new.intersection_update(result)
1254
1260
        return new
 
1261
 
 
1262
    @staticmethod
 
1263
    def _subtract_plans(old_plan, new_plan):
 
1264
        matcher = patiencediff.PatienceSequenceMatcher(None, old_plan,
 
1265
                                                       new_plan)
 
1266
        last_j = 0
 
1267
        for i, j, n in matcher.get_matching_blocks():
 
1268
            for jj in range(last_j, j):
 
1269
                yield new_plan[jj]
 
1270
            for jj in range(j, j+n):
 
1271
                plan_line = new_plan[jj]
 
1272
                if plan_line[0] == 'new-b':
 
1273
                    pass
 
1274
                elif plan_line[0] == 'killed-b':
 
1275
                    yield 'unchanged', plan_line[1]
 
1276
                else:
 
1277
                    yield plan_line
 
1278
            last_j = j + n