~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testrevision.py

  • Committer: Lalo Martins
  • Date: 2005-09-09 11:37:44 UTC
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050909113744-22f870db25a9e5f5
getting rid of everything that calls the Branch constructor directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    from bzrlib.commit import commit
23
23
    import os
24
24
    os.mkdir("branch1")
25
 
    br1 = Branch("branch1", init=True)
 
25
    br1 = Branch.initialize("branch1")
26
26
    
27
27
    commit(br1, "Commit one", rev_id="a@u-0-0")
28
28
    commit(br1, "Commit two", rev_id="a@u-0-1")
29
29
    commit(br1, "Commit three", rev_id="a@u-0-2")
30
30
 
31
31
    os.mkdir("branch2")
32
 
    br2 = Branch("branch2", init=True)
 
32
    br2 = Branch.initialize("branch2")
33
33
    br2.update_revisions(br1)
34
34
    commit(br2, "Commit four", rev_id="b@u-0-3")
35
35
    commit(br2, "Commit five", rev_id="b@u-0-4")
132
132
class TestCommonAncestor(TestCaseInTempDir):
133
133
    """Test checking whether a revision is an ancestor of another revision"""
134
134
 
135
 
    def test_old_common_ancestor(self):
136
 
        """Pick a resonable merge base using the old functionality"""
137
 
        from bzrlib.revision import find_present_ancestors
138
 
        from bzrlib.revision import old_common_ancestor as common_ancestor
 
135
    def test_common_ancestor(self):
 
136
        from bzrlib.revision import find_present_ancestors, common_ancestor
139
137
        from bzrlib.revision import MultipleRevisionSources
140
138
        br1, br2 = make_branches()
141
139
        revisions = br1.revision_history()
171
169
                          revisions[4])
172
170
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
173
171
                          revisions_2[5])
174
 
 
175
 
    def test_common_ancestor(self):
176
 
        """Pick a reasonable merge base"""
177
 
        from bzrlib.revision import find_present_ancestors
178
 
        from bzrlib.revision import common_ancestor
179
 
        from bzrlib.revision import MultipleRevisionSources
180
 
        br1, br2 = make_branches()
181
 
        revisions = br1.revision_history()
182
 
        revisions_2 = br2.revision_history()
183
 
        sources = MultipleRevisionSources(br1, br2)
184
 
 
185
 
        expected_ancestors_list = {revisions[3]:(0, 0), 
186
 
                                   revisions[2]:(1, 1),
187
 
                                   revisions_2[4]:(2, 1), 
188
 
                                   revisions[1]:(3, 2),
189
 
                                   revisions_2[3]:(4, 2),
190
 
                                   revisions[0]:(5, 3) }
191
 
        ancestors_list = find_present_ancestors(revisions[3], sources)
192
 
        assert len(expected_ancestors_list) == len(ancestors_list)
193
 
        for key, value in expected_ancestors_list.iteritems():
194
 
            self.assertEqual(ancestors_list[key], value, 
195
 
                              "key %r, %r != %r" % (key, ancestors_list[key],
196
 
                                                    value))
197
 
 
198
 
        self.assertEqual(common_ancestor(revisions[0], revisions[0], sources),
199
 
                          revisions[0])
200
 
        self.assertEqual(common_ancestor(revisions[1], revisions[2], sources),
201
 
                          revisions[1])
202
 
        self.assertEqual(common_ancestor(revisions[1], revisions[1], sources),
203
 
                          revisions[1])
204
 
        self.assertEqual(common_ancestor(revisions[2], revisions_2[4], sources),
205
 
                          revisions[2])
206
 
        self.assertEqual(common_ancestor(revisions[3], revisions_2[4], sources),
207
 
                          revisions_2[4])
208
 
        self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
209
 
                          revisions_2[4])
210
 
        self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
211
 
                          revisions[4])
212
 
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
213
 
                          revisions[4])
214