~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

[merge] update from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import os
19
19
 
20
 
from bzrlib.tests import TestCaseInTempDir
 
20
from bzrlib.tests import TestCaseWithTransport
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.commit import commit
23
23
from bzrlib.fetch import fetch
48
48
    so A is missing b6 at the start
49
49
    and B is missing a3, a4, a5
50
50
    """
51
 
    os.mkdir("branch1")
52
 
    br1 = Branch.initialize("branch1")
 
51
    tree1 = self.make_branch_and_tree("branch1")
 
52
    br1 = tree1.branch
53
53
    
54
 
    commit(br1, "Commit one", rev_id="a@u-0-0")
55
 
    commit(br1, "Commit two", rev_id="a@u-0-1")
56
 
    commit(br1, "Commit three", rev_id="a@u-0-2")
 
54
    tree1.commit("Commit one", rev_id="a@u-0-0")
 
55
    tree1.commit("Commit two", rev_id="a@u-0-1")
 
56
    tree1.commit("Commit three", rev_id="a@u-0-2")
57
57
 
58
 
    os.mkdir("branch2")
59
 
    br2 = Branch.initialize("branch2")
 
58
    tree2 = self.make_branch_and_tree("branch2")
 
59
    br2 = tree2.branch
60
60
    br2.update_revisions(br1)
61
 
    commit(br2, "Commit four", rev_id="b@u-0-3")
62
 
    commit(br2, "Commit five", rev_id="b@u-0-4")
 
61
    tree2.commit("Commit four", rev_id="b@u-0-3")
 
62
    tree2.commit("Commit five", rev_id="b@u-0-4")
63
63
    revisions_2 = br2.revision_history()
64
64
    
65
65
    fetch(from_branch=br2, to_branch=br1)
66
 
    br1.working_tree().add_pending_merge(revisions_2[4])
 
66
    tree1.add_pending_merge(revisions_2[4])
67
67
    self.assertEquals(revisions_2[4], 'b@u-0-4')
68
 
    commit(br1, "Commit six", rev_id="a@u-0-3")
69
 
    commit(br1, "Commit seven", rev_id="a@u-0-4")
70
 
    commit(br2, "Commit eight", rev_id="b@u-0-5")
 
68
    tree1.commit("Commit six", rev_id="a@u-0-3")
 
69
    tree1.commit("Commit seven", rev_id="a@u-0-4")
 
70
    tree2.commit("Commit eight", rev_id="b@u-0-5")
71
71
    
72
72
    fetch(from_branch=br2, to_branch=br1)
73
 
    br1.working_tree().add_pending_merge(br2.revision_history()[5])
74
 
    commit(br1, "Commit nine", rev_id="a@u-0-5")
 
73
    tree1.add_pending_merge(br2.revision_history()[5])
 
74
    tree1.commit("Commit nine", rev_id="a@u-0-5")
75
75
    # DO NOT FETCH HERE - we WANT a GHOST.
76
76
    #fetch(from_branch=br1, to_branch=br2)
77
 
    br2.working_tree().add_pending_merge(br1.revision_history()[4])
78
 
    commit(br2, "Commit ten - ghost merge", rev_id="b@u-0-6")
 
77
    tree2.add_pending_merge(br1.revision_history()[4])
 
78
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
79
79
    
80
80
    return br1, br2
81
81
 
82
82
 
83
 
class TestIsAncestor(TestCaseInTempDir):
 
83
class TestIsAncestor(TestCaseWithTransport):
 
84
 
84
85
    def test_recorded_ancestry(self):
85
86
        """Test that commit records all ancestors"""
86
87
        br1, br2 = make_branches(self)
112
113
                if rev_id in br2_only and not branch is br2:
113
114
                    continue
114
115
                mutter('ancestry of {%s}: %r',
115
 
                       rev_id, branch.get_ancestry(rev_id))
116
 
                self.assertEquals(sorted(branch.get_ancestry(rev_id)),
117
 
                                  [None] + sorted(anc))
 
116
                       rev_id, branch.repository.get_ancestry(rev_id))
 
117
                result = sorted(branch.repository.get_ancestry(rev_id))
 
118
                self.assertEquals(result, [None] + sorted(anc))
118
119
    
119
120
    
120
121
    def test_is_ancestor(self):
137
138
        ## self.assert_(not is_ancestor(revisions[3], revisions_2[3], br1))
138
139
 
139
140
 
140
 
class TestIntermediateRevisions(TestCaseInTempDir):
 
141
class TestIntermediateRevisions(TestCaseWithTransport):
141
142
 
142
143
    def setUp(self):
143
144
        from bzrlib.commit import commit
144
 
        TestCaseInTempDir.setUp(self)
 
145
        TestCaseWithTransport.setUp(self)
145
146
        self.br1, self.br2 = make_branches(self)
146
147
 
147
148
        self.br2.working_tree().commit("Commit eleven", rev_id="b@u-0-7")
157
158
        self.br2.working_tree().commit("Commit fifteen", rev_id="b@u-0-10")
158
159
 
159
160
        from bzrlib.revision import MultipleRevisionSources
160
 
        self.sources = MultipleRevisionSources(self.br1, self.br2)
 
161
        self.sources = MultipleRevisionSources(self.br1.repository,
 
162
                                               self.br2.repository)
161
163
 
162
164
    def intervene(self, ancestor, revision, revision_history=None):
163
165
        from bzrlib.revision import get_intervening_revisions
205
207
                          'c@u-0-6', self.br2.revision_history())
206
208
 
207
209
 
208
 
class TestCommonAncestor(TestCaseInTempDir):
 
210
class TestCommonAncestor(TestCaseWithTransport):
209
211
    """Test checking whether a revision is an ancestor of another revision"""
210
212
 
211
213
    def test_old_common_ancestor(self):
214
216
        br1, br2 = make_branches(self)
215
217
        revisions = br1.revision_history()
216
218
        revisions_2 = br2.revision_history()
217
 
        sources = br1
 
219
        sources = br1.repository
218
220
 
219
221
        expected_ancestors_list = {revisions[3]:(0, 0), 
220
222
                                   revisions[2]:(1, 1),
253
255
        br1, br2 = make_branches(self)
254
256
        revisions = br1.revision_history()
255
257
        revisions_2 = br2.revision_history()
256
 
        sources = MultipleRevisionSources(br1, br2)
 
258
        sources = MultipleRevisionSources(br1.repository, br2.repository)
257
259
        expected_ancestors_list = {revisions[3]:(0, 0), 
258
260
                                   revisions[2]:(1, 1),
259
261
                                   revisions_2[4]:(2, 1), 
288
290
        Ensure it's not order-sensitive
289
291
        """
290
292
        br1, br2 = make_branches(self)
291
 
        source = MultipleRevisionSources(br1, br2)
 
293
        source = MultipleRevisionSources(br1.repository, br2.repository)
292
294
        combined_1 = combined_graph(br1.last_revision(), 
293
295
                                    br2.last_revision(), source)
294
296
        combined_2 = combined_graph(br2.last_revision(),