/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 breezy/tests/test_graph.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
#     | | |
233
233
#     |/|/
234
234
#     t u
235
 
complex_shortcut2 = {'a':[NULL_REVISION], 'b':['a'], 'c':['b'], 'd':['c'],
236
 
                    'e':['d'], 'f':['e'], 'g':['f'], 'h':['d'], 'i':['g'],
237
 
                    'j':['h'], 'k':['h', 'i'], 'l':['k'], 'm':['l'], 'n':['m'],
238
 
                    'o':['n'], 'p':['o'], 'q':['p'], 'r':['q'], 's':['r'],
239
 
                    't':['i', 's'], 'u':['s', 'j'],
 
235
complex_shortcut2 = {'a': [NULL_REVISION], 'b': ['a'], 'c': ['b'], 'd': ['c'],
 
236
                    'e': ['d'], 'f': ['e'], 'g': ['f'], 'h': ['d'], 'i': ['g'],
 
237
                    'j': ['h'], 'k': ['h', 'i'], 'l': ['k'], 'm': ['l'], 'n': ['m'],
 
238
                    'o': ['n'], 'p': ['o'], 'q': ['p'], 'r': ['q'], 's': ['r'],
 
239
                    't': ['i', 's'], 'u': ['s', 'j'],
240
240
                    }
241
241
 
242
242
# Graph where different walkers will race to find the common and uncommon
894
894
    def test_heads_limits_search(self):
895
895
        # test that a heads query does not search all of history
896
896
        graph_dict = {
897
 
            'left':['common'],
898
 
            'right':['common'],
899
 
            'common':['deeper'],
 
897
            'left': ['common'],
 
898
            'right': ['common'],
 
899
            'common': ['deeper'],
900
900
        }
901
901
        self.assertEqual({'left', 'right'},
902
902
            self._run_heads_break_deeper(graph_dict, ['left', 'right']))
904
904
    def test_heads_limits_search_assymetric(self):
905
905
        # test that a heads query does not search all of history
906
906
        graph_dict = {
907
 
            'left':['midleft'],
908
 
            'midleft':['common'],
909
 
            'right':['common'],
910
 
            'common':['aftercommon'],
911
 
            'aftercommon':['deeper'],
 
907
            'left': ['midleft'],
 
908
            'midleft': ['common'],
 
909
            'right': ['common'],
 
910
            'common': ['aftercommon'],
 
911
            'aftercommon': ['deeper'],
912
912
        }
913
913
        self.assertEqual({'left', 'right'},
914
914
            self._run_heads_break_deeper(graph_dict, ['left', 'right']))
917
917
        # test that common nodes are still queried, preventing
918
918
        # all-the-way-to-origin behaviour in the following graph:
919
919
        graph_dict = {
920
 
            'h1':['shortcut', 'common1'],
921
 
            'h2':['common1'],
922
 
            'shortcut':['common2'],
923
 
            'common1':['common2'],
924
 
            'common2':['deeper'],
 
920
            'h1': ['shortcut', 'common1'],
 
921
            'h2': ['common1'],
 
922
            'shortcut': ['common2'],
 
923
            'common1': ['common2'],
 
924
            'common2': ['deeper'],
925
925
        }
926
926
        self.assertEqual({'h1', 'h2'},
927
927
            self._run_heads_break_deeper(graph_dict, ['h1', 'h2']))
939
939
 
940
940
    def test_breadth_first_search_deep_ghosts(self):
941
941
        graph = self.make_graph({
942
 
            'head':['present'],
943
 
            'present':['child', 'ghost'],
944
 
            'child':[],
 
942
            'head': ['present'],
 
943
            'present': ['child', 'ghost'],
 
944
            'child': [],
945
945
            })
946
946
        # with_ghosts reports the ghosts
947
947
        search = graph._make_breadth_first_searcher(['head'])
962
962
        # To make the API robust, we allow calling both next() and
963
963
        # next_with_ghosts() on the same searcher.
964
964
        graph = self.make_graph({
965
 
            'head':['present'],
966
 
            'present':['child', 'ghost'],
967
 
            'child':[],
 
965
            'head': ['present'],
 
966
            'present': ['child', 'ghost'],
 
967
            'child': [],
968
968
            })
969
969
        # start with next_with_ghosts
970
970
        search = graph._make_breadth_first_searcher(['head'])
984
984
    def test_breadth_first_change_search(self):
985
985
        # Changing the search should work with both next and next_with_ghosts.
986
986
        graph = self.make_graph({
987
 
            'head':['present'],
988
 
            'present':['stopped'],
989
 
            'other':['other_2'],
990
 
            'other_2':[],
 
987
            'head': ['present'],
 
988
            'present': ['stopped'],
 
989
            'other': ['other_2'],
 
990
            'other_2': [],
991
991
            })
992
992
        search = graph._make_breadth_first_searcher(['head'])
993
993
        self.assertEqual(({'head'}, set()), search.next_with_ghosts())
1035
1035
 
1036
1036
    def test_breadth_first_get_result_excludes_current_pending(self):
1037
1037
        graph = self.make_graph({
1038
 
            'head':['child'],
1039
 
            'child':[NULL_REVISION],
1040
 
            NULL_REVISION:[],
 
1038
            'head': ['child'],
 
1039
            'child': [NULL_REVISION],
 
1040
            NULL_REVISION: [],
1041
1041
            })
1042
1042
        search = graph._make_breadth_first_searcher(['head'])
1043
1043
        # At the start, nothing has been seen, to its all excluded:
1102
1102
        # A client should be able to say 'stop node X' even if X has not been
1103
1103
        # returned to the client.
1104
1104
        graph = self.make_graph({
1105
 
            'head':['child', 'ghost1'],
1106
 
            'child':[NULL_REVISION],
1107
 
            NULL_REVISION:[],
 
1105
            'head': ['child', 'ghost1'],
 
1106
            'child': [NULL_REVISION],
 
1107
            NULL_REVISION: [],
1108
1108
            })
1109
1109
        search = graph._make_breadth_first_searcher(['head'])
1110
1110
        expected = [
1128
1128
        # from the result even if X was seen in an older iteration of the
1129
1129
        # search.
1130
1130
        graph = self.make_graph({
1131
 
            'head':['middle'],
1132
 
            'middle':['child'],
1133
 
            'child':[NULL_REVISION],
1134
 
            NULL_REVISION:[],
 
1131
            'head': ['middle'],
 
1132
            'middle': ['child'],
 
1133
            'child': [NULL_REVISION],
 
1134
            NULL_REVISION: [],
1135
1135
            })
1136
1136
        search = graph._make_breadth_first_searcher(['head'])
1137
1137
        expected = [
1152
1152
 
1153
1153
    def test_breadth_first_get_result_ghosts_are_excluded(self):
1154
1154
        graph = self.make_graph({
1155
 
            'head':['child', 'ghost'],
1156
 
            'child':[NULL_REVISION],
1157
 
            NULL_REVISION:[],
 
1155
            'head': ['child', 'ghost'],
 
1156
            'child': [NULL_REVISION],
 
1157
            NULL_REVISION: [],
1158
1158
            })
1159
1159
        search = graph._make_breadth_first_searcher(['head'])
1160
1160
        # using next:
1173
1173
 
1174
1174
    def test_breadth_first_get_result_starting_a_ghost_ghost_is_excluded(self):
1175
1175
        graph = self.make_graph({
1176
 
            'head':['child'],
1177
 
            'child':[NULL_REVISION],
1178
 
            NULL_REVISION:[],
 
1176
            'head': ['child'],
 
1177
            'child': [NULL_REVISION],
 
1178
            NULL_REVISION: [],
1179
1179
            })
1180
1180
        search = graph._make_breadth_first_searcher(['head'])
1181
1181
        # using next:
1194
1194
 
1195
1195
    def test_breadth_first_revision_count_includes_NULL_REVISION(self):
1196
1196
        graph = self.make_graph({
1197
 
            'head':[NULL_REVISION],
1198
 
            NULL_REVISION:[],
 
1197
            'head': [NULL_REVISION],
 
1198
            NULL_REVISION: [],
1199
1199
            })
1200
1200
        search = graph._make_breadth_first_searcher(['head'])
1201
1201
        # using next:
1215
1215
    def test_breadth_first_search_get_result_after_StopIteration(self):
1216
1216
        # StopIteration should not invalid anything..
1217
1217
        graph = self.make_graph({
1218
 
            'head':[NULL_REVISION],
1219
 
            NULL_REVISION:[],
 
1218
            'head': [NULL_REVISION],
 
1219
            NULL_REVISION: [],
1220
1220
            })
1221
1221
        search = graph._make_breadth_first_searcher(['head'])
1222
1222
        # using next: