~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

[merge] land Robert's branch-formats branch

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)
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")
206
207
                          'c@u-0-6', self.br2.revision_history())
207
208
 
208
209
 
209
 
class TestCommonAncestor(TestCaseInTempDir):
 
210
class TestCommonAncestor(TestCaseWithTransport):
210
211
    """Test checking whether a revision is an ancestor of another revision"""
211
212
 
212
213
    def test_old_common_ancestor(self):