/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-12 18:06:30 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080712180630-5hc93d3s2vff9olo
Start refactoring into helper functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
773
773
                          ('unchanged', 'g\n')],
774
774
                         list(plan))
775
775
 
 
776
    def assertRemoveExternalReferences(self, filtered_parent_map,
 
777
                                       child_map, tails, parent_map):
 
778
        """Assert results for _PlanMerge._remove_external_references."""
 
779
        (act_filtered_parent_map, act_child_map,
 
780
         act_tails) = _PlanMerge._remove_external_references(parent_map)
 
781
 
 
782
        # The parent map *should* preserve ordering, but the ordering of
 
783
        # children is not strictly defined
 
784
        # child_map = dict((k, sorted(children))
 
785
        #                  for k, children in child_map.iteritems())
 
786
        # act_child_map = dict(k, sorted(children)
 
787
        #                      for k, children in act_child_map.iteritems())
 
788
        self.assertEqual(filtered_parent_map, act_filtered_parent_map)
 
789
        self.assertEqual(child_map, act_child_map)
 
790
        self.assertEqual(sorted(tails), sorted(act_tails))
 
791
 
 
792
    def test__remove_external_references(self):
 
793
        # First, nothing to remove
 
794
        self.assertRemoveExternalReferences({3: [2], 2: [1], 1: []},
 
795
            {1: [2], 2: [3], 3: []}, [1], {3: [2], 2: [1], 1: []})
 
796
        # The reverse direction
 
797
        self.assertRemoveExternalReferences({1: [2], 2: [3], 3: []},
 
798
            {3: [2], 2: [1], 1: []}, [3], {1: [2], 2: [3], 3: []})
 
799
        # Extra references
 
800
        self.assertRemoveExternalReferences({3: [2], 2: [1], 1: []},
 
801
            {1: [2], 2: [3], 3: []}, [1], {3: [2, 4], 2: [1, 5], 1: [6]})
 
802
        # Multiple tails
 
803
        self.assertRemoveExternalReferences(
 
804
            {4: [2, 3], 3: [], 2: [1], 1: []},
 
805
            {1: [2], 2: [4], 3: [4], 4: []},
 
806
            [1, 3],
 
807
            {4: [2, 3], 3: [5], 2: [1], 1: [6]})
 
808
        # Multiple children
 
809
        self.assertRemoveExternalReferences(
 
810
            {1: [3], 2: [3, 4], 3: [], 4: []},
 
811
            {1: [], 2: [], 3: [1, 2], 4: [2]},
 
812
            [3, 4],
 
813
            {1: [3], 2: [3, 4], 3: [5], 4: []})
 
814
 
776
815
    def test_subtract_plans(self):
777
816
        old_plan = [
778
817
        ('unchanged', 'a\n'),