~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-10 18:54:29 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080710185429-w5k3hqv7dfpc9o2b
Write a (failing) test for complex ancestry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
500
500
            plan._get_matching_blocks('B', 'C')),
501
501
            ([1, 2, 3], [0, 2]))
502
502
 
 
503
    def test_plan_merge(self):
 
504
        self.setup_plan_merge()
 
505
        plan = self.plan_merge_vf.plan_merge('B', 'C')
 
506
        self.assertEqual([
 
507
                          ('new-b', 'f\n'),
 
508
                          ('unchanged', 'a\n'),
 
509
                          ('killed-a', 'b\n'),
 
510
                          ('killed-b', 'c\n'),
 
511
                          ('new-b', 'g\n'),
 
512
                          ('new-a', 'e\n'),
 
513
                          ('new-a', 'h\n'),
 
514
                          ('new-a', 'g\n')],
 
515
                         list(plan))
 
516
 
503
517
    def test_plan_merge_cherrypick(self):
504
518
        self.add_version(('root', 'A'), [], 'abc')
505
519
        self.add_version(('root', 'B'), [('root', 'A')], 'abcde')
530
544
                          ('new-a', 'c\n')],
531
545
                          list(my_plan.plan_merge()))
532
546
 
533
 
    def test_plan_merge(self):
534
 
        self.setup_plan_merge()
535
 
        plan = self.plan_merge_vf.plan_merge('B', 'C')
536
 
        self.assertEqual([
537
 
                          ('new-b', 'f\n'),
538
 
                          ('unchanged', 'a\n'),
539
 
                          ('killed-a', 'b\n'),
540
 
                          ('killed-b', 'c\n'),
541
 
                          ('new-b', 'g\n'),
542
 
                          ('new-a', 'e\n'),
543
 
                          ('new-a', 'h\n'),
544
 
                          ('new-a', 'g\n')],
545
 
                         list(plan))
546
 
 
547
547
    def test_plan_merge_uncommitted_files(self):
548
548
        self.setup_plan_merge_uncommitted()
549
549
        plan = self.plan_merge_vf.plan_merge('B:', 'C:')
558
558
                          ('new-a', 'g\n')],
559
559
                         list(plan))
560
560
 
 
561
    def test_plan_merge_criss_cross(self):
 
562
        # This is specificly trying to trigger problems when using limited
 
563
        # ancestry and weaves. The ancestry graph looks like:
 
564
        #       A       Unique LCA
 
565
        #       |\
 
566
        #       B \     Introduces a line 'foo'
 
567
        #      / \ \
 
568
        #     C   D E   C & D both have 'foo', E has different changes
 
569
        #     |\ /| |
 
570
        #     | X | |
 
571
        #     |/ \|/
 
572
        #     F   G      All of C, D, E are merged into F and G, so they are
 
573
        #                all common ancestors.
 
574
        #
 
575
        # The specific issue with weaves:
 
576
        #   B introduced a text ('foo') that is present in both C and D.
 
577
        #   If we do not include B (because it isn't an ancestor of E), then
 
578
        #   the A=>C and A=>D look like both sides independently introduce the
 
579
        #   text ('foo'). If F does not modify the text, it would still appear
 
580
        #   to have deleted on of the versions from C or D. If G then modifies
 
581
        #   'foo', it should appear as superseding the value in F (since it
 
582
        #   came from B), rather than conflict because of the resolution during
 
583
        #   C & D.
 
584
        self.add_version(('root', 'A'), [], 'abcdef')
 
585
        self.add_version(('root', 'B'), [('root', 'A')], 'axcdef')
 
586
        self.add_version(('root', 'C'), [('root', 'B')], 'axcdefg')
 
587
        self.add_version(('root', 'D'), [('root', 'B')], 'haxcdef')
 
588
        self.add_version(('root', 'E'), [('root', 'A')], 'abcdyf')
 
589
        self.add_version(('root', 'F'),
 
590
                         [('root', 'C'), ('root', 'D'), ('root', 'E')],
 
591
                         'haxcdyfg') #Simple combining of all texts
 
592
        self.add_version(('root', 'G'),
 
593
                         [('root', 'C'), ('root', 'D'), ('root', 'E')],
 
594
                         'hazcdyfg') #combining and supersede 'x'
 
595
        plan = self.plan_merge_vf.plan_merge('F', 'G')
 
596
        self.assertEqual([
 
597
                          ('unchanged', 'h\n'),
 
598
                          ('unchanged', 'a\n'),
 
599
                          ('killed-b', 'x\n'),
 
600
                          ('new-b', 'z\n'),
 
601
                          ('unchanged', 'c\n'),
 
602
                          ('unchanged', 'd\n'),
 
603
                          ('killed-base', 'e\n'),
 
604
                          ('unchanged', 'y\n'),
 
605
                          ('unchanged', 'f\n'),
 
606
                          ('unchanged', 'g\n')],
 
607
                         list(plan))
 
608
 
561
609
    def test_subtract_plans(self):
562
610
        old_plan = [
563
611
        ('unchanged', 'a\n'),