~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testrevision.py

  • Committer: Aaron Bentley
  • Date: 2005-08-25 13:10:25 UTC
  • mfrom: (974.1.38)
  • mto: (1092.1.42) (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: abentley@panoramicfeedback.com-20050825131025-2aa94bcbbd646a00
Fixed return value when not an ImmutableStore

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
 
49
49
class TestIsAncestor(InTempDir):
50
 
 
51
 
    def test_is_ancestor(self):
52
 
        """Test checking whether a revision is an ancestor of another revision"""
 
50
    """Test checking whether a revision is an ancestor of another revision"""
 
51
    def runTest(self):
53
52
        from bzrlib.revision import is_ancestor, MultipleRevisionSources
54
53
        from bzrlib.errors import NoSuchRevision
55
54
        br1, br2 = make_branches()
68
67
        assert is_ancestor(revisions[3], revisions_2[3], sources)
69
68
        assert not is_ancestor(revisions[3], revisions_2[3], br1)
70
69
 
71
 
class TestIntermediateRevisions(InTempDir):
72
 
 
73
 
    def setUp(self):
74
 
        from bzrlib.commit import commit
75
 
        InTempDir.setUp(self)
76
 
        self.br1, self.br2 = make_branches()
77
 
        commit(self.br2, "Commit eleven", rev_id="b@u-0-7")
78
 
        commit(self.br2, "Commit twelve", rev_id="b@u-0-8")
79
 
        commit(self.br2, "Commit thirtteen", rev_id="b@u-0-9")
80
 
        self.br1.add_pending_merge(self.br2.revision_history()[6])
81
 
        commit(self.br1, "Commit fourtten", rev_id="a@u-0-6")
82
 
        self.br2.add_pending_merge(self.br1.revision_history()[6])
83
 
        commit(self.br2, "Commit fifteen", rev_id="b@u-0-10")
84
 
 
85
 
        from bzrlib.revision import MultipleRevisionSources
86
 
        self.sources = MultipleRevisionSources(self.br1, self.br2)
87
 
 
88
 
    def intervene(self, ancestor, revision, revision_history=None):
89
 
        from bzrlib.revision import get_intervening_revisions
90
 
        return get_intervening_revisions(ancestor,revision, self.sources, 
91
 
                                         revision_history)
92
 
 
93
 
    def test_intervene(self):
94
 
        """Find intermediate revisions, without requiring history"""
95
 
        from bzrlib.errors import NotAncestor, NoSuchRevision
96
 
        assert len(self.intervene('a@u-0-0', 'a@u-0-0')) == 0
97
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-1'), ['a@u-0-1'])
98
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-2'), 
99
 
                         ['a@u-0-1', 'a@u-0-2'])
100
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-3'), 
101
 
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3'])
102
 
        self.assertEqual(self.intervene('b@u-0-3', 'a@u-0-3'), 
103
 
                         ['b@u-0-4', 'a@u-0-3'])
104
 
        self.assertEqual(self.intervene('a@u-0-2', 'a@u-0-3', 
105
 
                                        self.br1.revision_history()), 
106
 
                         ['a@u-0-3'])
107
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-5', 
108
 
                                        self.br1.revision_history()), 
109
 
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
110
 
                          'a@u-0-5'])
111
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6', 
112
 
                         self.br1.revision_history()), 
113
 
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
114
 
                          'b@u-0-6'])
115
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'), 
116
 
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4', 
117
 
                          'b@u-0-5'])
118
 
        self.assertEqual(self.intervene('b@u-0-3', 'b@u-0-6', 
119
 
                         self.br2.revision_history()), 
120
 
                         ['b@u-0-4', 'b@u-0-5', 'b@u-0-6'])
121
 
        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10'), 
122
 
                         ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
123
 
        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10', 
124
 
                                        self.br2.revision_history()), 
125
 
                         ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
126
 
        self.assertRaises(NotAncestor, self.intervene, 'b@u-0-10', 'b@u-0-6', 
127
 
                          self.br2.revision_history())
128
 
        self.assertRaises(NoSuchRevision, self.intervene, 'c@u-0-10', 
129
 
                          'b@u-0-6', self.br2.revision_history())
130
 
        self.assertRaises(NoSuchRevision, self.intervene, 'b@u-0-10', 
131
 
                          'c@u-0-6', self.br2.revision_history())
132
 
 
133
70
 
134
71
class TestCommonAncestor(InTempDir):
135
72
    """Test checking whether a revision is an ancestor of another revision"""
136
 
 
137
 
    def test_common_ancestor(self):
 
73
    def runTest(self):
138
74
        from bzrlib.revision import find_present_ancestors, common_ancestor
139
75
        from bzrlib.revision import MultipleRevisionSources
140
76
        br1, br2 = make_branches()
171
107
                          revisions[4])
172
108
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
173
109
                          revisions_2[5])
 
110
 
 
111
TEST_CLASSES = [
 
112
    TestIsAncestor,
 
113
    TestCommonAncestor,
 
114
    ]