/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_index.py

  • Committer: John Arbash Meinel
  • Date: 2009-08-13 19:56:26 UTC
  • mto: This revision was merged to the branch mainline in revision 4613.
  • Revision ID: john@arbash-meinel.com-20090813195626-tlsu5cexc1q8lzmr
Name the specific index api _find_ancestors, and the public CombinedGraphIndex api find_ancestry()

Show diffs side-by-side

added added

removed removed

Lines of Context:
953
953
            ])
954
954
        self.assertEqual(set([]), index.external_references(0))
955
955
 
956
 
    def test_get_ancestry(self):
 
956
    def test__find_ancestors(self):
957
957
        key1 = ('key-1',)
958
958
        key2 = ('key-2',)
959
959
        index = self.make_index(ref_lists=1, key_elements=1, nodes=[
962
962
            ])
963
963
        parent_map = {}
964
964
        missing_keys = set()
965
 
        search_keys = index.get_ancestry([key1], 0, parent_map, missing_keys)
 
965
        search_keys = index._find_ancestors([key1], 0, parent_map, missing_keys)
966
966
        self.assertEqual({key1: (key2,)}, parent_map)
967
967
        self.assertEqual(set(), missing_keys)
968
968
        self.assertEqual(set([key2]), search_keys)
969
 
        search_keys = index.get_ancestry(search_keys, 0, parent_map,
970
 
                                         missing_keys)
 
969
        search_keys = index._find_ancestors(search_keys, 0, parent_map,
 
970
                                            missing_keys)
971
971
        self.assertEqual({key1: (key2,), key2: ()}, parent_map)
972
972
        self.assertEqual(set(), missing_keys)
973
973
        self.assertEqual(set(), search_keys)
974
974
 
975
 
    def test_get_ancestry_w_missing(self):
 
975
    def test__find_ancestors_w_missing(self):
976
976
        key1 = ('key-1',)
977
977
        key2 = ('key-2',)
978
978
        key3 = ('key-3',)
982
982
            ])
983
983
        parent_map = {}
984
984
        missing_keys = set()
985
 
        search_keys = index.get_ancestry([key2, key3], 0, parent_map,
986
 
                                         missing_keys)
 
985
        search_keys = index._find_ancestors([key2, key3], 0, parent_map,
 
986
                                            missing_keys)
987
987
        self.assertEqual({key2: ()}, parent_map)
988
988
        self.assertEqual(set([key3]), missing_keys)
989
989
        self.assertEqual(set(), search_keys)
990
990
 
991
 
    def test_get_ancestry_dont_search_known(self):
 
991
    def test__find_ancestors_dont_search_known(self):
992
992
        key1 = ('key-1',)
993
993
        key2 = ('key-2',)
994
994
        key3 = ('key-3',)
1000
1000
        # We already know about key2, so we won't try to search for key3
1001
1001
        parent_map = {key2: (key3,)}
1002
1002
        missing_keys = set()
1003
 
        search_keys = index.get_ancestry([key1], 0, parent_map,
1004
 
                                         missing_keys)
 
1003
        search_keys = index._find_ancestors([key1], 0, parent_map,
 
1004
                                            missing_keys)
1005
1005
        self.assertEqual({key1: (key2,), key2: (key3,)}, parent_map)
1006
1006
        self.assertEqual(set(), missing_keys)
1007
1007
        self.assertEqual(set(), search_keys)
1324
1324
                                    ['1', '2', '3'])
1325
1325
        self.assertRaises(errors.NoSuchFile, index.validate)
1326
1326
 
1327
 
    def test_get_ancestry_across_indexes(self):
 
1327
    def test_find_ancestors_across_indexes(self):
1328
1328
        key1 = ('key-1',)
1329
1329
        key2 = ('key-2',)
1330
1330
        key3 = ('key-3',)
1338
1338
            (key4, 'value', ([key3],)),
1339
1339
            ])
1340
1340
        c_index = CombinedGraphIndex([index1, index2])
1341
 
        parent_map, missing_keys = c_index.get_ancestry([key1])
 
1341
        parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1342
1342
        self.assertEqual({key1: ()}, parent_map)
1343
1343
        self.assertEqual(set(), missing_keys)
1344
1344
        # Now look for a key from index2 which requires us to find the key in
1345
1345
        # the second index, and then continue searching for parents in the
1346
1346
        # first index
1347
 
        parent_map, missing_keys = c_index.get_ancestry([key3])
 
1347
        parent_map, missing_keys = c_index.find_ancestry([key3], 0)
1348
1348
        self.assertEqual({key1: (), key2: (key1,), key3: (key2,)}, parent_map)
1349
1349
        self.assertEqual(set(), missing_keys)
1350
1350
 
1351
 
    def test_get_ancestry_missing_keys(self):
 
1351
    def test_find_ancestors_missing_keys(self):
1352
1352
        key1 = ('key-1',)
1353
1353
        key2 = ('key-2',)
1354
1354
        key3 = ('key-3',)
1363
1363
        c_index = CombinedGraphIndex([index1, index2])
1364
1364
        # Searching for a key which is actually not present at all should
1365
1365
        # eventually converge
1366
 
        parent_map, missing_keys = c_index.get_ancestry([key4])
 
1366
        parent_map, missing_keys = c_index.find_ancestry([key4], 0)
1367
1367
        self.assertEqual({}, parent_map)
1368
1368
        self.assertEqual(set([key4]), missing_keys)
1369
1369
 
1370
 
    def test_get_ancestry_no_indexes(self):
 
1370
    def test_find_ancestors_no_indexes(self):
1371
1371
        c_index = CombinedGraphIndex([])
1372
1372
        key1 = ('key-1',)
1373
 
        parent_map, missing_keys = c_index.get_ancestry([key1])
 
1373
        parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1374
1374
        self.assertEqual({}, parent_map)
1375
1375
        self.assertEqual(set([key1]), missing_keys)
1376
1376
 
1377
 
    def test_get_ancestry_ghost_parent(self):
 
1377
    def test_find_ancestors_ghost_parent(self):
1378
1378
        key1 = ('key-1',)
1379
1379
        key2 = ('key-2',)
1380
1380
        key3 = ('key-3',)
1389
1389
        c_index = CombinedGraphIndex([index1, index2])
1390
1390
        # Searching for a key which is actually not present at all should
1391
1391
        # eventually converge
1392
 
        parent_map, missing_keys = c_index.get_ancestry([key4])
 
1392
        parent_map, missing_keys = c_index.find_ancestry([key4], 0)
1393
1393
        self.assertEqual({key4: (key2, key3), key2: (key1,), key1: ()},
1394
1394
                         parent_map)
1395
1395
        self.assertEqual(set([key3]), missing_keys)
1396
1396
 
1397
 
    def test_get_ancestry_empty_index(self):
1398
 
        index = self.make_index(ref_lists=1, key_elements=1, nodes=[])
 
1397
    def test__find_ancestors_empty_index(self):
 
1398
        index = self.make_index('test', ref_lists=1, key_elements=1, nodes=[])
1399
1399
        parent_map = {}
1400
1400
        missing_keys = set()
1401
 
        search_keys = index.get_ancestry([('one',), ('two',)], 0, parent_map,
1402
 
                                         missing_keys)
 
1401
        search_keys = index._find_ancestors([('one',), ('two',)], 0, parent_map,
 
1402
                                            missing_keys)
1403
1403
        self.assertEqual(set(), search_keys)
1404
1404
        self.assertEqual({}, parent_map)
1405
1405
        self.assertEqual(set([('one',), ('two',)]), missing_keys)