~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Robert Collins
  • Date: 2009-05-11 01:59:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090511015906-6zi6a9b8tuuhipc8
Less lock thrashing in check.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2007 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
26
25
 
27
26
 
28
27
# Ancestry 1:
675
674
        self.assertEqual((set(['e']), set(['f', 'g'])),
676
675
                         graph.find_difference('e', 'f'))
677
676
 
678
 
 
679
677
    def test_stacked_parents_provider(self):
680
678
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
681
679
        parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
682
 
        stacked = _mod_graph.StackedParentsProvider([parents1, parents2])
683
 
        self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
684
 
                         stacked.get_parent_map(['rev1', 'rev2']))
685
 
        self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
686
 
                         stacked.get_parent_map(['rev2', 'rev1']))
687
 
        self.assertEqual({'rev2':['rev3']},
688
 
                         stacked.get_parent_map(['rev2', 'rev2']))
689
 
        self.assertEqual({'rev1':['rev4']},
690
 
                         stacked.get_parent_map(['rev1', 'rev1']))
691
 
    
692
 
    def test_stacked_parents_provider_overlapping(self):
693
 
        # rev2 is availible in both providers.
694
 
        # 1
695
 
        # |
696
 
        # 2
697
 
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev1']})
698
 
        parents2 = _mod_graph.DictParentsProvider({'rev2': ['rev1']})
699
 
        stacked = _mod_graph.StackedParentsProvider([parents1, parents2])
700
 
        self.assertEqual({'rev2': ['rev1']},
701
 
                         stacked.get_parent_map(['rev2']))
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])
 
680
        stacked = _mod_graph._StackedParentsProvider([parents1, parents2])
708
681
        self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
709
682
                         stacked.get_parent_map(['rev1', 'rev2']))
710
683
        self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
1598
1571
        result = _mod_graph.PendingAncestryResult(['rev-2'], repo)
1599
1572
        self.assertEqual(set(['rev-1', 'rev-2']), set(result.get_keys()))
1600
1573
 
1601
 
    def test_get_keys_excludes_ghosts(self):
1602
 
        builder = self.make_branch_builder('b')
1603
 
        builder.start_series()
1604
 
        builder.build_snapshot('rev-1', None, [
1605
 
            ('add', ('', 'root-id', 'directory', ''))])
1606
 
        builder.build_snapshot('rev-2', ['rev-1', 'ghost'], [])
1607
 
        builder.finish_series()
1608
 
        repo = builder.get_branch().repository
1609
 
        repo.lock_read()
1610
 
        self.addCleanup(repo.unlock)
1611
 
        result = _mod_graph.PendingAncestryResult(['rev-2'], repo)
1612
 
        self.assertEqual(sorted(['rev-1', 'rev-2']), sorted(result.get_keys()))
1613
 
 
1614
1574
    def test_get_keys_excludes_null(self):
1615
1575
        # Make a 'graph' with an iter_ancestry that returns NULL_REVISION
1616
1576
        # somewhere other than the last element, which can happen in real