~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-19 08:36:50 UTC
  • mfrom: (1664.2.14 bzr.knitplanmerge)
  • Revision ID: pqm@pqm.ubuntu.com-20060419083650-f26d296f90d75d88
Implement plan_merge for knits

Show diffs side-by-side

added added

removed removed

Lines of Context:
368
368
        self.assertEqual(['revid', 'revid2', 'revid3'], knit.versions())
369
369
        self.assertEqual(['revid2'], knit.get_parents('revid3'))
370
370
 
 
371
    def test_plan_merge(self):
 
372
        my_knit = self.make_test_knit(annotate=True)
 
373
        my_knit.add_lines('text1', [], split_lines(TEXT_1))
 
374
        my_knit.add_lines('text1a', ['text1'], split_lines(TEXT_1A))
 
375
        my_knit.add_lines('text1b', ['text1'], split_lines(TEXT_1B))
 
376
        plan = list(my_knit.plan_merge('text1a', 'text1b'))
 
377
        for plan_line, expected_line in zip(plan, AB_MERGE):
 
378
            self.assertEqual(plan_line, expected_line)
371
379
 
372
380
 
373
381
TEXT_1 = """\
388
396
- self-raising flour
389
397
"""
390
398
 
 
399
TEXT_1B = """\
 
400
Banana cup cake recipe
 
401
 
 
402
- bananas (do not use plantains!!!)
 
403
- broken tea cups
 
404
- flour
 
405
"""
 
406
 
391
407
delta_1_1a = """\
392
408
0,1,2
393
409
Banana cup cake recipe
406
422
- mushrooms
407
423
"""
408
424
 
 
425
AB_MERGE_TEXT="""unchanged|Banana cup cake recipe
 
426
new-a|(serves 6)
 
427
unchanged|
 
428
killed-b|- bananas
 
429
killed-b|- eggs
 
430
new-b|- bananas (do not use plantains!!!)
 
431
unchanged|- broken tea cups
 
432
new-a|- self-raising flour
 
433
new-b|- flour
 
434
"""
 
435
AB_MERGE=[tuple(l.split('|')) for l in AB_MERGE_TEXT.splitlines(True)]
 
436
 
 
437
 
409
438
def line_delta(from_lines, to_lines):
410
439
    """Generate line-based delta from one text to another"""
411
440
    s = difflib.SequenceMatcher(None, from_lines, to_lines)