~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Robert Collins
  • Date: 2006-03-22 16:26:09 UTC
  • mto: (1666.1.5 integration)
  • mto: This revision was merged to the branch mainline in revision 1622.
  • Revision ID: robertc@robertcollins.net-20060322162609-fd4ba4a57afd33ed
Fix common_ancestor to still calculate a common ancestor when ghosts are
present along all paths of ancestry - there are no 'import' revisions
available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from bzrlib.tests import TestCase
2
 
from bzrlib.graph import node_distances, nodes_by_distance
 
2
from bzrlib.graph import node_distances, nodes_by_distance, Graph
3
3
 
4
4
class TestBase(TestCase):
 
5
 
5
6
    def edge_add(self, *args):
6
7
        for start, end in zip(args[:-1], args[1:]):
7
8
            if start not in self.graph:
47
48
        distances = node_distances(self.graph, descendants, 'A')
48
49
        self.assertEqual(distances['C'], 3)
49
50
 
 
51
 
 
52
class TestGraph(TestCase):
 
53
 
 
54
    def test_get_descendants(self):
 
55
        # Graph objects let you get a descendants graph in 
 
56
        # node: {direct-children:distance} which contains
 
57
        # known children, including ghost children
 
58
        graph = Graph()
 
59
        graph.add_ghost('ghost')
 
60
        graph.add_node('rev1', ['ghost'])
 
61
        # check the result contains ghosts:
 
62
        self.assertEqual({'ghost': {'rev1': 1}, 'rev1': {}},
 
63
                         graph.get_descendants())