~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_revision_history.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    revision as _mod_revision,
23
23
    )
24
24
from bzrlib.symbol_versioning import deprecated_in
25
 
from bzrlib.tests import per_branch
 
25
from bzrlib.tests import (
 
26
    per_branch,
 
27
    TestNotApplicable,
 
28
    )
26
29
 
27
30
 
28
31
class TestLastRevision(per_branch.TestCaseWithBranch):
39
42
        br = self.get_branch()
40
43
        br.fetch(wt.branch)
41
44
        br.set_last_revision_info(1, 'rev1')
42
 
        self.assertEquals(br.revision_history(), ["rev1",])
 
45
        self.assertEquals(
 
46
            self.applyDeprecated(deprecated_in((2, 5, 0)), br.revision_history),
 
47
            ["rev1",])
43
48
        br.set_last_revision_info(3, 'rev3')
44
 
        self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
 
49
        self.assertEquals(
 
50
            self.applyDeprecated(deprecated_in((2, 5, 0)), br.revision_history),
 
51
            ["rev1", "rev2", "rev3"])
45
52
        # append_revision specifically prohibits some ids;
46
53
        # set_last_revision_info currently does not
47
54
        ## self.assertRaises(errors.ReservedId,
85
92
        """
86
93
        branch, calls = self.get_instrumented_branch()
87
94
        # Repeatedly call revision_history.
88
 
        branch.revision_history()
89
 
        branch.revision_history()
 
95
        self.applyDeprecated(deprecated_in((2, 5, 0)), branch.revision_history)
 
96
        self.applyDeprecated(deprecated_in((2, 5, 0)), branch.revision_history)
90
97
        self.assertEqual(
91
98
            ['_gen_revision_history', '_gen_revision_history'], calls)
92
99
 
98
105
        # Lock the branch, then repeatedly call revision_history.
99
106
        branch.lock_read()
100
107
        try:
101
 
            branch.revision_history()
102
 
            branch.revision_history()
 
108
            self.applyDeprecated(deprecated_in((2, 5, 0)),
 
109
                branch.revision_history)
 
110
            self.applyDeprecated(deprecated_in((2, 5, 0)),
 
111
                branch.revision_history)
103
112
            self.assertEqual(['_gen_revision_history'], calls)
104
113
        finally:
105
114
            branch.unlock()
116
125
        self.applyDeprecated(deprecated_in((2, 4, 0)),
117
126
            branch.set_revision_history, [])
118
127
        try:
119
 
            branch.revision_history()
 
128
            self.applyDeprecated(deprecated_in((2, 5, 0)),
 
129
                branch.revision_history)
120
130
            self.assertEqual([], calls)
121
131
        finally:
122
132
            branch.unlock()
128
138
        branch, calls = self.get_instrumented_branch()
129
139
        self.applyDeprecated(deprecated_in((2, 4, 0)),
130
140
            branch.set_revision_history, [])
131
 
        branch.revision_history()
 
141
        self.applyDeprecated(deprecated_in((2, 5, 0)),
 
142
            branch.revision_history)
132
143
        self.assertEqual(['_gen_revision_history'], calls)
133
144
 
134
145
    def test_set_last_revision_info_when_locked(self):
168
179
        a_branch, calls = self.get_instrumented_branch()
169
180
        # Lock the branch, cache the revision history.
170
181
        a_branch.lock_write()
171
 
        a_branch.revision_history()
 
182
        self.applyDeprecated(deprecated_in((2, 5, 0)),
 
183
            a_branch.revision_history)
172
184
        # Set the last revision info, clearing the cache.
173
185
        a_branch.set_last_revision_info(0, _mod_revision.NULL_REVISION)
174
186
        del calls[:]
175
187
        try:
176
 
            a_branch.revision_history()
 
188
            self.applyDeprecated(deprecated_in((2, 5, 0)),
 
189
                a_branch.revision_history)
177
190
            self.assertEqual(['_gen_revision_history'], calls)
178
191
        finally:
179
192
            a_branch.unlock()
189
202
        branch.lock_read()
190
203
        try:
191
204
            # The first time the data returned will not be in the cache.
192
 
            history = branch.revision_history()
 
205
            history = self.applyDeprecated(deprecated_in((2, 5, 0)),
 
206
                branch.revision_history)
193
207
            history.append('one')
194
208
            # The second time the data comes from the cache.
195
 
            history = branch.revision_history()
 
209
            history = self.applyDeprecated(deprecated_in((2, 5, 0)),
 
210
                branch.revision_history)
196
211
            history.append('two')
197
212
            # The revision_history() should still be unchanged, even though
198
213
            # we've mutated the return values from earlier calls.
199
 
            self.assertEqual([], branch.revision_history())
 
214
            self.assertEqual([], self.applyDeprecated(
 
215
                deprecated_in((2, 5, 0)), branch.revision_history))
200
216
        finally:
201
217
            branch.unlock()
202
218
 
205
221
 
206
222
    def test_parent_ghost(self):
207
223
        tree = self.make_branch_and_tree('tree')
 
224
        if not tree.branch.repository._format.supports_ghosts:
 
225
            raise TestNotApplicable("repository format does not support ghosts")
208
226
        tree.add_parent_tree_id('ghost-revision',
209
227
                                allow_leftmost_as_ghost=True)
210
228
        tree.commit('first non-ghost commit', rev_id='non-ghost-revision')
211
229
        self.assertEqual(['non-ghost-revision'],
212
 
                         tree.branch.revision_history())
 
230
                         self.applyDeprecated(deprecated_in((2, 5, 0)),
 
231
                            tree.branch.revision_history))