/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_dirstate.py

  • Committer: Martin Pool
  • Date: 2007-10-03 08:06:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071003080644-oivy0gkg98sex0ed
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).

Add new LockFailed, which doesn't imply that we failed to get it because of
contention.  Raise this if we fail to create the pending or lock directories
because of Transport errors.

UnlockableTransport is not an internal error.

ReadOnlyLockError has a message which didn't match its name or usage; it's now
deprecated and callers are updated to use LockFailed which is more appropriate.

Add zero_ninetytwo deprecation symbol.

Unify assertMatchesRe with TestCase.assertContainsRe.

When the constructor is deprecated, just say that the class is deprecated, not
the __init__ method - this works better with applyDeprecated in tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Benchmarks for bzr DirState performance."""
18
18
 
26
26
    tests,
27
27
    )
28
28
from bzrlib.tests.test__dirstate_helpers import (
29
 
    compiled_dirstate_helpers_feature,
 
29
    CompiledDirstateHelpersFeature,
30
30
    )
31
31
 
32
32
 
194
194
            state.unlock()
195
195
 
196
196
    def test__read_dirblocks_20k_tree_0_parents_py(self):
197
 
        from bzrlib._dirstate_helpers_py import _read_dirblocks
 
197
        from bzrlib._dirstate_helpers_py import _read_dirblocks_py
198
198
        state = self.build_20k_dirstate()
199
199
        state.lock_read()
200
200
        try:
201
201
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
202
202
                             state._dirblock_state)
203
203
            state._read_header_if_needed()
204
 
            self.time(_read_dirblocks, state)
 
204
            self.time(_read_dirblocks_py, state)
205
205
        finally:
206
206
            state.unlock()
207
207
 
208
 
    def test__read_dirblocks_20k_tree_0_parents_pyx(self):
209
 
        self.requireFeature(compiled_dirstate_helpers_feature)
210
 
        from bzrlib._dirstate_helpers_pyx import _read_dirblocks
 
208
    def test__read_dirblocks_20k_tree_0_parents_c(self):
 
209
        self.requireFeature(CompiledDirstateHelpersFeature)
 
210
        from bzrlib._dirstate_helpers_c import _read_dirblocks_c
211
211
        state = self.build_20k_dirstate()
212
212
        state.lock_read()
213
213
        try:
214
214
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
215
215
                             state._dirblock_state)
216
216
            state._read_header_if_needed()
217
 
            self.time(_read_dirblocks, state)
 
217
            self.time(_read_dirblocks_c, state)
218
218
        finally:
219
219
            state.unlock()
220
220
 
221
221
    def test__read_dirblocks_20k_tree_1_parent_py(self):
222
 
        from bzrlib._dirstate_helpers_py import _read_dirblocks
 
222
        from bzrlib._dirstate_helpers_py import _read_dirblocks_py
223
223
        state = self.build_20k_dirstate_with_parents(1)
224
224
        state.lock_read()
225
225
        try:
226
226
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
227
227
                             state._dirblock_state)
228
228
            state._read_header_if_needed()
229
 
            self.time(_read_dirblocks, state)
 
229
            self.time(_read_dirblocks_py, state)
230
230
        finally:
231
231
            state.unlock()
232
232
 
233
 
    def test__read_dirblocks_20k_tree_1_parent_pyx(self):
234
 
        self.requireFeature(compiled_dirstate_helpers_feature)
235
 
        from bzrlib._dirstate_helpers_pyx import _read_dirblocks
 
233
    def test__read_dirblocks_20k_tree_1_parent_c(self):
 
234
        self.requireFeature(CompiledDirstateHelpersFeature)
 
235
        from bzrlib._dirstate_helpers_c import _read_dirblocks_c
236
236
        state = self.build_20k_dirstate_with_parents(1)
237
237
        state.lock_read()
238
238
        try:
239
239
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
240
240
                             state._dirblock_state)
241
241
            state._read_header_if_needed()
242
 
            self.time(_read_dirblocks, state)
 
242
            self.time(_read_dirblocks_c, state)
243
243
        finally:
244
244
            state.unlock()
245
245
 
246
246
    def test__read_dirblocks_20k_tree_2_parents_py(self):
247
 
        from bzrlib._dirstate_helpers_py import _read_dirblocks
 
247
        from bzrlib._dirstate_helpers_py import _read_dirblocks_py
248
248
        state = self.build_20k_dirstate_with_parents(2)
249
249
        state.lock_read()
250
250
        try:
251
251
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
252
252
                             state._dirblock_state)
253
253
            state._read_header_if_needed()
254
 
            self.time(_read_dirblocks, state)
 
254
            self.time(_read_dirblocks_py, state)
255
255
        finally:
256
256
            state.unlock()
257
257
 
258
 
    def test__read_dirblocks_20k_tree_2_parents_pyx(self):
259
 
        self.requireFeature(compiled_dirstate_helpers_feature)
260
 
        from bzrlib._dirstate_helpers_pyx import _read_dirblocks
 
258
    def test__read_dirblocks_20k_tree_2_parents_c(self):
 
259
        self.requireFeature(CompiledDirstateHelpersFeature)
 
260
        from bzrlib._dirstate_helpers_c import _read_dirblocks_c
261
261
        state = self.build_20k_dirstate_with_parents(2)
262
262
        state.lock_read()
263
263
        try:
264
264
            self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
265
265
                             state._dirblock_state)
266
266
            state._read_header_if_needed()
267
 
            self.time(_read_dirblocks, state)
 
267
            self.time(_read_dirblocks_c, state)
268
268
        finally:
269
269
            state.unlock()
270
270
 
313
313
        self.assertEqualDiff(expected_str, offset_str)
314
314
 
315
315
    def test_bisect_dirblock_py(self):
316
 
        from bzrlib._dirstate_helpers_py import bisect_dirblock
 
316
        from bzrlib._dirstate_helpers_py import bisect_dirblock_py
317
317
        state = self.build_10k_dirstate_dirs()
318
318
        state.lock_read()
319
319
        try:
320
320
            self.setup_paths_and_offsets(state)
321
321
            offsets = self.time(self.do_bisect_list,
322
 
                                bisect_dirblock)
 
322
                                bisect_dirblock_py)
323
323
            self.checkOffsets(offsets)
324
324
        finally:
325
325
            state.unlock()
326
326
 
327
327
    def test_bisect_dirblock_cached_py(self):
328
 
        from bzrlib._dirstate_helpers_py import bisect_dirblock
 
328
        from bzrlib._dirstate_helpers_py import bisect_dirblock_py
329
329
        state = self.build_10k_dirstate_dirs()
330
330
        state.lock_read()
331
331
        try:
332
332
            self.setup_paths_and_offsets(state)
333
333
            offsets = self.time(self.do_bisect_list_cached,
334
 
                                bisect_dirblock)
 
334
                                bisect_dirblock_py)
335
335
            self.checkOffsets(offsets)
336
336
        finally:
337
337
            state.unlock()
338
338
 
339
 
    def test_bisect_dirblock_pyx(self):
340
 
        self.requireFeature(compiled_dirstate_helpers_feature)
341
 
        from bzrlib._dirstate_helpers_pyx import bisect_dirblock
 
339
    def test_bisect_dirblock_c(self):
 
340
        self.requireFeature(CompiledDirstateHelpersFeature)
 
341
        from bzrlib._dirstate_helpers_c import bisect_dirblock_c
342
342
        state = self.build_10k_dirstate_dirs()
343
343
        state.lock_read()
344
344
        try:
345
345
            self.setup_paths_and_offsets(state)
346
 
            offsets = self.time(self.do_bisect_list, bisect_dirblock)
 
346
            offsets = self.time(self.do_bisect_list, bisect_dirblock_c)
347
347
            self.checkOffsets(offsets)
348
348
        finally:
349
349
            state.unlock()
415
415
 
416
416
    def test_cmp_by_dirs_py(self):
417
417
        """Benchmark 103041 comparisons."""
418
 
        from bzrlib._dirstate_helpers_py import cmp_by_dirs
419
 
        self.compareAllPaths(cmp_by_dirs,
 
418
        from bzrlib._dirstate_helpers_py import cmp_by_dirs_py
 
419
        self.compareAllPaths(cmp_by_dirs_py,
420
420
                             [(3, 1), (3, 1), (3, 1), (3, 2)])
421
421
 
422
 
    def test_cmp_by_dirs_pyrex(self):
423
 
        self.requireFeature(compiled_dirstate_helpers_feature)
424
 
        from bzrlib._dirstate_helpers_pyx import cmp_by_dirs
425
 
        self.compareAllPaths(cmp_by_dirs,
 
422
    def test_cmp_by_dirs_c(self):
 
423
        self.requireFeature(CompiledDirstateHelpersFeature)
 
424
        from bzrlib._dirstate_helpers_c import cmp_by_dirs_c
 
425
        self.compareAllPaths(cmp_by_dirs_c,
426
426
                             [(3, 1), (3, 1), (3, 1), (3, 2)])