~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

merge 2.0 branch rev 4647

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
    )
23
23
from bzrlib.revision import NULL_REVISION
24
24
from bzrlib.tests import TestCaseWithMemoryTransport
25
 
from bzrlib.symbol_versioning import deprecated_in 
 
25
from bzrlib.symbol_versioning import deprecated_in
26
26
 
27
27
 
28
28
# Ancestry 1:
526
526
        graph = self.make_graph(history_shortcut)
527
527
        self.assertEqual(set(['rev2b']), graph.find_lca('rev3a', 'rev3b'))
528
528
 
 
529
    def test_lefthand_distance_smoke(self):
 
530
        """A simple does it work test for graph.lefthand_distance(keys)."""
 
531
        graph = self.make_graph(history_shortcut)
 
532
        distance_graph = graph.find_lefthand_distances(['rev3b', 'rev2a'])
 
533
        self.assertEqual({'rev2a': 2, 'rev3b': 3}, distance_graph)
 
534
 
 
535
    def test_lefthand_distance_ghosts(self):
 
536
        """A simple does it work test for graph.lefthand_distance(keys)."""
 
537
        nodes = {'nonghost':[NULL_REVISION], 'toghost':['ghost']}
 
538
        graph = self.make_graph(nodes)
 
539
        distance_graph = graph.find_lefthand_distances(['nonghost', 'toghost'])
 
540
        self.assertEqual({'nonghost': 1, 'toghost': -1}, distance_graph)
 
541
 
529
542
    def test_recursive_unique_lca(self):
530
543
        """Test finding a unique least common ancestor.
531
544