~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Aaron Bentley
  • Date: 2010-08-15 14:28:35 UTC
  • mto: (5365.6.7 annotate-revspec)
  • mto: This revision was merged to the branch mainline in revision 5443.
  • Revision ID: aaron@aaronbentley.com-20100815142835-iqbryps5woojcesr
Implement find_descendants.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1424
1424
        self.assertMergeOrder(['rev3', 'rev1'], graph, 'rev4', ['rev1', 'rev3'])
1425
1425
 
1426
1426
 
 
1427
class TestFindDescendants(TestGraphBase):
 
1428
 
 
1429
    def test_find_descendants_rev1_rev3(self):
 
1430
        graph = self.make_graph(ancestry_1)
 
1431
        descendants = graph.find_descendants('rev1', 'rev3')
 
1432
        self.assertEqual(set(['rev1', 'rev2a', 'rev3']), descendants)
 
1433
 
 
1434
    def test_find_descendants_rev1_rev4(self):
 
1435
        graph = self.make_graph(ancestry_1)
 
1436
        descendants = graph.find_descendants('rev1', 'rev4')
 
1437
        self.assertEqual(set(['rev1', 'rev2a', 'rev2b', 'rev3', 'rev4']),
 
1438
                         descendants)
 
1439
 
 
1440
    def test_find_descendants_rev2a_rev4(self):
 
1441
        graph = self.make_graph(ancestry_1)
 
1442
        descendants = graph.find_descendants('rev2a', 'rev4')
 
1443
        self.assertEqual(set(['rev2a', 'rev3', 'rev4']), descendants)
 
1444
 
 
1445
 
 
1446
class TestGetChildMap(TestGraphBase):
 
1447
 
 
1448
    def test_get_child_map(self):
 
1449
        graph = self.make_graph(ancestry_1)
 
1450
        child_map = graph.get_child_map(['rev4', 'rev3', 'rev2a', 'rev2b'])
 
1451
        self.assertEqual({'rev1': ['rev2a', 'rev2b'],
 
1452
                          'rev2a': ['rev3'],
 
1453
                          'rev2b': ['rev4'],
 
1454
                          'rev3': ['rev4']},
 
1455
                          child_map)
 
1456
 
 
1457
 
1427
1458
class TestCachingParentsProvider(tests.TestCase):
1428
1459
    """These tests run with:
1429
1460