756
756
search = graph._make_breadth_first_searcher(['head'])
757
757
# At the start, nothing has been seen, to its all excluded:
758
self.assertEqual((set(['head']), set(['head'])), search.get_recipe())
758
self.assertEqual((set(['head']), set(['head']), 0),
759
760
self.assertEqual(set(), search.seen)
762
(set(['head']), (set(['head']), set(['child'])), None, None),
763
(set(['head', 'child']), (set(['head']), set([NULL_REVISION])),
763
(set(['head']), (set(['head']), set(['child']), 1), None, None),
764
(set(['head', 'child']), (set(['head']), set([NULL_REVISION]), 2),
765
(set(['head', 'child', NULL_REVISION]), (set(['head']), set()),
766
(set(['head', 'child', NULL_REVISION]), (set(['head']), set(), 3),
768
769
self.assertSeenAndRecipes(expected, search, search.next)
791
793
# - otherhead counts as seen immediately when start_searching is
793
795
(set(['head', 'child', 'otherhead']),
794
(set(['head', 'otherhead']), set(['child', 'otherchild'])),
796
(set(['head', 'otherhead']), set(['child', 'otherchild']), 2),
795
797
['otherhead'], ['child']),
796
798
(set(['head', 'child', 'otherhead', 'otherchild']),
797
(set(['head', 'otherhead']), set(['child', 'excluded'])),
799
(set(['head', 'otherhead']), set(['child', 'excluded']), 3),
799
# stop searchind otherexcluded now
801
# stop searching excluded now
800
802
(set(['head', 'child', 'otherhead', 'otherchild', 'excluded']),
801
(set(['head', 'otherhead']), set(['child', 'excluded'])),
803
(set(['head', 'otherhead']), set(['child', 'excluded']), 3),
802
804
None, ['excluded']),
804
806
self.assertSeenAndRecipes(expected, search, search.next)
820
(set(['head']), set(['ghost', 'child'])),
822
(set(['head']), set(['ghost', 'child']), 1),
822
824
(set(['head', 'child', 'ghost']),
823
(set(['head']), set([NULL_REVISION, 'ghost'])),
825
(set(['head']), set([NULL_REVISION, 'ghost']), 2),
826
828
self.assertSeenAndRecipes(expected, search, search.next)
840
842
(set(['head', 'ghost']),
841
(set(['head', 'ghost']), set(['child', 'ghost'])),
843
(set(['head', 'ghost']), set(['child', 'ghost']), 1),
842
844
['ghost'], None),
843
845
(set(['head', 'child', 'ghost']),
844
(set(['head', 'ghost']), set([NULL_REVISION, 'ghost'])),
847
self.assertSeenAndRecipes(expected, search, search.next)
848
# using next_with_ghosts:
849
search = graph._make_breadth_first_searcher(['head'])
850
self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
846
(set(['head', 'ghost']), set([NULL_REVISION, 'ghost']), 2),
849
self.assertSeenAndRecipes(expected, search, search.next)
850
# using next_with_ghosts:
851
search = graph._make_breadth_first_searcher(['head'])
852
self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
854
def test_breadth_first_revision_count_includes_NULL_REVISION(self):
855
graph = self.make_graph({
856
'head':[NULL_REVISION],
859
search = graph._make_breadth_first_searcher(['head'])
863
(set(['head']), set([NULL_REVISION]), 1),
865
(set(['head', NULL_REVISION]),
866
(set(['head']), set([]), 2),
869
self.assertSeenAndRecipes(expected, search, search.next)
870
# using next_with_ghosts:
871
search = graph._make_breadth_first_searcher(['head'])
872
self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
874
def test_breadth_first_search_get_recipe_after_StopIteration(self):
875
# StopIteration should not invalid anything..
876
graph = self.make_graph({
877
'head':[NULL_REVISION],
880
search = graph._make_breadth_first_searcher(['head'])
884
(set(['head']), set([NULL_REVISION]), 1),
886
(set(['head', 'ghost', NULL_REVISION]),
887
(set(['head', 'ghost']), set(['ghost']), 2),
890
self.assertSeenAndRecipes(expected, search, search.next)
891
self.assertRaises(StopIteration, search.next)
892
self.assertEqual(set(['head', 'ghost', NULL_REVISION]), search.seen)
893
self.assertEqual((set(['ghost', 'head']), set(['ghost']), 2),
895
# using next_with_ghosts:
896
search = graph._make_breadth_first_searcher(['head'])
897
self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
898
self.assertRaises(StopIteration, search.next)
899
self.assertEqual(set(['head', 'ghost', NULL_REVISION]), search.seen)
900
self.assertEqual((set(['ghost', 'head']), set(['ghost']), 2),
853
905
class TestCachingParentsProvider(tests.TestCase):