~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Zearin
  • Date: 2010-11-12 22:36:19 UTC
  • mto: (5570.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5572.
  • Revision ID: zearin@users.sourceforge.net-20101112223619-1i2oscfgg1xgzuqk
Continued capitalization fixes ([S]FTP, SSH).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011 Canonical Ltd
 
1
# Copyright (C) 2007-2010 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
17
17
from bzrlib import (
18
18
    errors,
19
19
    graph as _mod_graph,
 
20
    symbol_versioning,
20
21
    tests,
21
22
    )
22
23
from bzrlib.revision import NULL_REVISION
23
24
from bzrlib.tests import TestCaseWithMemoryTransport
 
25
from bzrlib.symbol_versioning import deprecated_in
24
26
 
25
27
 
26
28
# Ancestry 1:
698
700
        self.assertEqual({'rev2': ['rev1']},
699
701
                         stacked.get_parent_map(['rev2']))
700
702
 
 
703
    def test__stacked_parents_provider_deprecated(self):
 
704
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
 
705
        parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
 
706
        stacked = self.applyDeprecated(deprecated_in((1, 16, 0)),
 
707
                    _mod_graph._StackedParentsProvider, [parents1, parents2])
 
708
        self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
 
709
                         stacked.get_parent_map(['rev1', 'rev2']))
 
710
        self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
 
711
                         stacked.get_parent_map(['rev2', 'rev1']))
 
712
        self.assertEqual({'rev2':['rev3']},
 
713
                         stacked.get_parent_map(['rev2', 'rev2']))
 
714
        self.assertEqual({'rev1':['rev4']},
 
715
                         stacked.get_parent_map(['rev1', 'rev1']))
 
716
 
701
717
    def test_iter_topo_order(self):
702
718
        graph = self.make_graph(ancestry_1)
703
719
        args = ['rev2a', 'rev3', 'rev1']
1638
1654
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'C'])))
1639
1655
        self.assertEqual(['B', 'C'], sorted(graph_thunk.heads(['B', 'C'])))
1640
1656
 
1641
 
    def test_add_node(self):
1642
 
        d = {('C',):[('A',)], ('B',): [('A',)], ('A',): []}
1643
 
        g = _mod_graph.KnownGraph(d)
1644
 
        graph_thunk = _mod_graph.GraphThunkIdsToKeys(g)
1645
 
        graph_thunk.add_node("D", ["A", "C"])
1646
 
        self.assertEqual(['B', 'D'],
1647
 
            sorted(graph_thunk.heads(['D', 'B', 'A'])))
1648
 
 
1649
 
    def test_merge_sort(self):
1650
 
        d = {('C',):[('A',)], ('B',): [('A',)], ('A',): []}
1651
 
        g = _mod_graph.KnownGraph(d)
1652
 
        graph_thunk = _mod_graph.GraphThunkIdsToKeys(g)
1653
 
        graph_thunk.add_node("D", ["A", "C"])
1654
 
        self.assertEqual([('C', 0, (2,), False), ('A', 0, (1,), True)],
1655
 
            [(n.key, n.merge_depth, n.revno, n.end_of_merge)
1656
 
                 for n in graph_thunk.merge_sort('C')])
1657
 
 
1658
1657
 
1659
1658
class TestPendingAncestryResultGetKeys(TestCaseWithMemoryTransport):
1660
1659
    """Tests for bzrlib.graph.PendingAncestryResult."""