~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: 2008-03-15 21:00:35 UTC
  • mfrom: (3228.4.15 revision_graph)
  • Revision ID: pqm@pqm.ubuntu.com-20080315210035-5qwda8bre2nwsra3
(jam) Update PackRepo.get_revision_graph() to efficiently handle
        ghosts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
            'f':[NULL_REVISION]}
239
239
 
240
240
 
 
241
# A graph that contains a ghost
 
242
#  NULL_REVISION
 
243
#       |
 
244
#       f
 
245
#       |
 
246
#       e   g
 
247
#      / \ /
 
248
#     b   d
 
249
#     | \ |
 
250
#     a   c
 
251
 
 
252
with_ghost = {'a': ['b'], 'c': ['b', 'd'], 'b':['e'], 'd':['e', 'g'],
 
253
              'e': ['f'], 'f':[NULL_REVISION], NULL_REVISION:()}
 
254
 
 
255
 
 
256
 
241
257
class InstrumentedParentsProvider(object):
242
258
 
243
259
    def __init__(self, parents_provider):
489
505
        self.assertFalse(graph.is_ancestor('a', 'c'))
490
506
        self.assertTrue('null:' not in instrumented_provider.calls)
491
507
 
 
508
    def test_iter_ancestry(self):
 
509
        nodes = boundary.copy()
 
510
        nodes[NULL_REVISION] = ()
 
511
        graph = self.make_graph(nodes)
 
512
        expected = nodes.copy()
 
513
        expected.pop('a') # 'a' is not in the ancestry of 'c', all the
 
514
                          # other nodes are
 
515
        self.assertEqual(expected, dict(graph.iter_ancestry(['c'])))
 
516
        self.assertEqual(nodes, dict(graph.iter_ancestry(['a', 'c'])))
 
517
 
 
518
    def test_iter_ancestry_with_ghost(self):
 
519
        graph = self.make_graph(with_ghost)
 
520
        expected = with_ghost.copy()
 
521
        # 'a' is not in the ancestry of 'c', and 'g' is a ghost
 
522
        expected['g'] = None
 
523
        self.assertEqual(expected, dict(graph.iter_ancestry(['a', 'c'])))
 
524
        expected.pop('a') 
 
525
        self.assertEqual(expected, dict(graph.iter_ancestry(['c'])))
 
526
 
492
527
    def test_filter_candidate_lca(self):
493
528
        """Test filter_candidate_lca for a corner case
494
529