~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Martin Pool
  • Date: 2006-02-22 04:29:54 UTC
  • mfrom: (1566 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060222042954-60333f08dd56a646
[merge] from bzr.dev before integration
Fix undefined ordering in sign_my_revisions breaking tests

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 TestCaseWithTransport
21
20
from bzrlib.branch import Branch
 
21
from bzrlib.errors import NoSuchRevision
22
22
from bzrlib.commit import commit
23
 
from bzrlib.fetch import fetch
24
23
from bzrlib.revision import (find_present_ancestors, combined_graph,
25
24
                             is_ancestor, MultipleRevisionSources)
 
25
from bzrlib.tests import TestCaseWithTransport
26
26
from bzrlib.trace import mutter
27
 
from bzrlib.errors import NoSuchRevision
 
27
from bzrlib.workingtree import WorkingTree
28
28
 
29
29
# XXX: Make this a method of a merge base case
30
30
def make_branches(self):
62
62
    tree2.commit("Commit five", rev_id="b@u-0-4")
63
63
    revisions_2 = br2.revision_history()
64
64
    
65
 
    fetch(from_branch=br2, to_branch=br1)
 
65
    br1.fetch(br2)
66
66
    tree1.add_pending_merge(revisions_2[4])
67
67
    self.assertEquals(revisions_2[4], 'b@u-0-4')
68
68
    tree1.commit("Commit six", rev_id="a@u-0-3")
69
69
    tree1.commit("Commit seven", rev_id="a@u-0-4")
70
70
    tree2.commit("Commit eight", rev_id="b@u-0-5")
71
71
    
72
 
    fetch(from_branch=br2, to_branch=br1)
 
72
    br1.fetch(br2)
73
73
    tree1.add_pending_merge(br2.revision_history()[5])
74
74
    tree1.commit("Commit nine", rev_id="a@u-0-5")
75
75
    # DO NOT FETCH HERE - we WANT a GHOST.
76
 
    #fetch(from_branch=br1, to_branch=br2)
 
76
    # br2.fetch(br1)
77
77
    tree2.add_pending_merge(br1.revision_history()[4])
78
78
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
79
79
    
144
144
        from bzrlib.commit import commit
145
145
        TestCaseWithTransport.setUp(self)
146
146
        self.br1, self.br2 = make_branches(self)
147
 
 
148
 
        self.br2.working_tree().commit("Commit eleven", rev_id="b@u-0-7")
149
 
        self.br2.working_tree().commit("Commit twelve", rev_id="b@u-0-8")
150
 
        self.br2.working_tree().commit("Commit thirtteen", rev_id="b@u-0-9")
151
 
 
152
 
        fetch(from_branch=self.br2, to_branch=self.br1)
153
 
        self.br1.working_tree().add_pending_merge(self.br2.revision_history()[6])
154
 
        self.br1.working_tree().commit("Commit fourtten", rev_id="a@u-0-6")
155
 
 
156
 
        fetch(from_branch=self.br1, to_branch=self.br2)
157
 
        self.br2.working_tree().add_pending_merge(self.br1.revision_history()[6])
158
 
        self.br2.working_tree().commit("Commit fifteen", rev_id="b@u-0-10")
 
147
        wt1 = self.br1.bzrdir.open_workingtree()
 
148
        wt2 = self.br2.bzrdir.open_workingtree()
 
149
        wt2.commit("Commit eleven", rev_id="b@u-0-7")
 
150
        wt2.commit("Commit twelve", rev_id="b@u-0-8")
 
151
        wt2.commit("Commit thirtteen", rev_id="b@u-0-9")
 
152
 
 
153
        self.br1.fetch(self.br2)
 
154
        wt1.add_pending_merge(self.br2.revision_history()[6])
 
155
        wt1.commit("Commit fourtten", rev_id="a@u-0-6")
 
156
 
 
157
        self.br2.fetch(self.br1)
 
158
        wt2.add_pending_merge(self.br1.revision_history()[6])
 
159
        wt2.commit("Commit fifteen", rev_id="b@u-0-10")
159
160
 
160
161
        from bzrlib.revision import MultipleRevisionSources
161
162
        self.sources = MultipleRevisionSources(self.br1.repository,
243
244
                          revisions_2[4])
244
245
        self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
245
246
                          revisions_2[4])
246
 
        fetch(from_branch=br2, to_branch=br1)
 
247
        br1.fetch(br2)
247
248
        self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
248
249
                          revisions[4]) # revisions_2[5] is equally valid
249
250
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
299
300
        self.assertEquals(combined_1[2], combined_2[2])
300
301
        self.assertEquals(combined_1[3], combined_2[3])
301
302
        self.assertEquals(combined_1, combined_2)
 
303
 
 
304
    def test_get_history(self):
 
305
        # TODO: test ghosts on the left hand branch's impact
 
306
        # TODO: test ghosts on all parents, we should get some
 
307
        # indicator. i.e. NULL_REVISION
 
308
        # RBC 20060608
 
309
        tree = self.make_branch_and_tree('.')
 
310
        tree.commit('1', rev_id = '1', allow_pointless=True)
 
311
        tree.commit('2', rev_id = '2', allow_pointless=True)
 
312
        tree.commit('3', rev_id = '3', allow_pointless=True)
 
313
        rev = tree.branch.repository.get_revision('1')
 
314
        history = rev.get_history(tree.branch.repository)
 
315
        self.assertEqual([None, '1'], history)
 
316
        rev = tree.branch.repository.get_revision('2')
 
317
        history = rev.get_history(tree.branch.repository)
 
318
        self.assertEqual([None, '1', '2'], history)
 
319
        rev = tree.branch.repository.get_revision('3')
 
320
        history = rev.get_history(tree.branch.repository)
 
321
        self.assertEqual([None, '1', '2' ,'3'], history)