~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 20:21:55 UTC
  • mfrom: (974.1.41)
  • mto: (1092.1.42) (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: abentley@panoramicfeedback.com-20050825202155-fd1b58eb8867b367
Initial 'intervening revisions' implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        assert is_ancestor(revisions[3], revisions_2[3], sources)
68
68
        assert not is_ancestor(revisions[3], revisions_2[3], br1)
69
69
 
 
70
class TestIntermediateRevisions(InTempDir):
 
71
    def setUp(self):
 
72
        from bzrlib.commit import commit
 
73
        self.br1, self.br2 = make_branches()
 
74
        commit(self.br2, "Commit eleven", rev_id="b@u-0-7")
 
75
        commit(self.br2, "Commit twelve", rev_id="b@u-0-8")
 
76
        commit(self.br2, "Commit thirtteen", rev_id="b@u-0-9")
 
77
        self.br1.add_pending_merge(self.br2.revision_history()[6])
 
78
        commit(self.br1, "Commit fourtten", rev_id="a@u-0-6")
 
79
        self.br2.add_pending_merge(self.br1.revision_history()[6])
 
80
        commit(self.br2, "Commit fifteen", rev_id="b@u-0-10")
 
81
 
 
82
        from bzrlib.revision import MultipleRevisionSources
 
83
        self.sources = MultipleRevisionSources(self.br1, self.br2)
 
84
 
 
85
    def intervene(self, ancestor, revision, revision_history=None):
 
86
        from bzrlib.revision import get_intervening_revisions
 
87
        return get_intervening_revisions(ancestor,revision, self.sources, 
 
88
                                         revision_history)
 
89
 
 
90
    def runTest(self):
 
91
        """Find intermediate revisions, without requiring history"""
 
92
        assert len(self.intervene('a@u-0-0', 'a@u-0-0')) == 0
 
93
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-1'), ['a@u-0-1'])
 
94
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-2'), 
 
95
                         ['a@u-0-1', 'a@u-0-2'])
 
96
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-3'), 
 
97
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3'])
 
98
        self.assertEqual(self.intervene('b@u-0-3', 'a@u-0-3'), 
 
99
                         ['b@u-0-4', 'a@u-0-3'])
 
100
        self.assertEqual(self.intervene('a@u-0-2', 'a@u-0-3'), 
 
101
                         ['a@u-0-3'])
 
102
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-5', 
 
103
                                        self.br1.revision_history()), 
 
104
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
 
105
                          'a@u-0-5'])
 
106
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6', 
 
107
                         self.br1.revision_history()), 
 
108
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
 
109
                          'b@u-0-6'])
 
110
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'), 
 
111
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4', 
 
112
                          'b@u-0-5'])
 
113
        self.assertEqual(self.intervene('b@u-0-3', 'b@u-0-6'), 
 
114
                         ['b@u-0-4', 'b@u-0-5', 'b@u-0-6'])
 
115
        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10'), 
 
116
                         ['a@u-0-6', 'b@u-0-10'])
 
117
#        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10', 
 
118
#                                        self.br2.revision_history()), 
 
119
#                         ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
 
120
 
70
121
 
71
122
class TestCommonAncestor(InTempDir):
72
123
    """Test checking whether a revision is an ancestor of another revision"""
111
162
TEST_CLASSES = [
112
163
    TestIsAncestor,
113
164
    TestCommonAncestor,
 
165
    TestIntermediateRevisions,
114
166
    ]