~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-30 04:49:31 UTC
  • mfrom: (4819.2.6 2.1.0b4-convert-kg-heads)
  • Revision ID: pqm@pqm.ubuntu.com-20091130044931-b5rjfh24zq1d3lju
(jam) Improve conversion efficiency by using a better heads()
        implementation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1582
1582
        self.assertCollapsed(d, d)
1583
1583
 
1584
1584
 
 
1585
class TestGraphThunkIdsToKeys(tests.TestCase):
 
1586
 
 
1587
    def test_heads(self):
 
1588
        # A
 
1589
        # |\
 
1590
        # B C
 
1591
        # |/
 
1592
        # D
 
1593
        d = {('D',): [('B',), ('C',)], ('C',):[('A',)],
 
1594
             ('B',): [('A',)], ('A',): []}
 
1595
        g = _mod_graph.Graph(_mod_graph.DictParentsProvider(d))
 
1596
        graph_thunk = _mod_graph.GraphThunkIdsToKeys(g)
 
1597
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'A'])))
 
1598
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'B'])))
 
1599
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'C'])))
 
1600
        self.assertEqual(['B', 'C'], sorted(graph_thunk.heads(['B', 'C'])))
 
1601
 
 
1602
 
1585
1603
class TestPendingAncestryResultGetKeys(TestCaseWithMemoryTransport):
1586
1604
    """Tests for bzrlib.graph.PendingAncestryResult."""
1587
1605