~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_versionedfile.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 00:49:50 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909004950-43z4zdicb5u91iet
tweak quick reference naming to make it consistent with other PDFs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2009 Canonical Ltd
2
2
#
3
3
# Authors:
4
4
#   Johan Rydberg <jrydberg@gnu.org>
734
734
        # the ordering here is to make a tree so that dumb searches have
735
735
        # more changes to muck up.
736
736
 
737
 
        class InstrumentedProgress(progress.ProgressTask):
 
737
        class InstrumentedProgress(progress.DummyProgress):
738
738
 
739
739
            def __init__(self):
740
 
                progress.ProgressTask.__init__(self)
 
740
 
 
741
                progress.DummyProgress.__init__(self)
741
742
                self.updates = []
742
743
 
743
744
            def update(self, msg=None, current=None, total=None):
1469
1470
            transport.mkdir('.')
1470
1471
        files = self.factory(transport)
1471
1472
        if self.cleanup is not None:
1472
 
            self.addCleanup(self.cleanup, files)
 
1473
            self.addCleanup(lambda:self.cleanup(files))
1473
1474
        return files
1474
1475
 
1475
1476
    def get_simple_key(self, suffix):
1580
1581
        # All texts should be output.
1581
1582
        self.assertEqual(set(keys), seen)
1582
1583
 
1583
 
    def test_clear_cache(self):
1584
 
        files = self.get_versionedfiles()
1585
 
        files.clear_cache()
1586
 
 
1587
1584
    def test_construct(self):
1588
1585
        """Each parameterised test can be constructed on a transport."""
1589
1586
        files = self.get_versionedfiles()
2437
2434
        else:
2438
2435
            self.assertIdenticalVersionedFile(source, files)
2439
2436
 
2440
 
    def test_insert_record_stream_long_parent_chain_out_of_order(self):
2441
 
        """An out of order stream can either error or work."""
2442
 
        if not self.graph:
2443
 
            raise TestNotApplicable('ancestry info only relevant with graph.')
2444
 
        # Create a reasonably long chain of records based on each other, where
2445
 
        # most will be deltas.
2446
 
        source = self.get_versionedfiles('source')
2447
 
        parents = ()
2448
 
        keys = []
2449
 
        content = [('same same %d\n' % n) for n in range(500)]
2450
 
        for letter in 'abcdefghijklmnopqrstuvwxyz':
2451
 
            key = ('key-' + letter,)
2452
 
            if self.key_length == 2:
2453
 
                key = ('prefix',) + key
2454
 
            content.append('content for ' + letter + '\n')
2455
 
            source.add_lines(key, parents, content)
2456
 
            keys.append(key)
2457
 
            parents = (key,)
2458
 
        # Create a stream of these records, excluding the first record that the
2459
 
        # rest ultimately depend upon, and insert it into a new vf.
2460
 
        streams = []
2461
 
        for key in reversed(keys):
2462
 
            streams.append(source.get_record_stream([key], 'unordered', False))
2463
 
        deltas = chain(*streams[:-1])
2464
 
        files = self.get_versionedfiles()
2465
 
        try:
2466
 
            files.insert_record_stream(deltas)
2467
 
        except RevisionNotPresent:
2468
 
            # Must not have corrupted the file.
2469
 
            files.check()
2470
 
        else:
2471
 
            # Must only report either just the first key as a missing parent,
2472
 
            # no key as missing (for nodelta scenarios).
2473
 
            missing = set(files.get_missing_compression_parent_keys())
2474
 
            missing.discard(keys[0])
2475
 
            self.assertEqual(set(), missing)
2476
 
 
2477
2437
    def get_knit_delta_source(self):
2478
2438
        """Get a source that can produce a stream with knit delta records,
2479
2439
        regardless of this test's scenario.
2547
2507
        # the ordering here is to make a tree so that dumb searches have
2548
2508
        # more changes to muck up.
2549
2509
 
2550
 
        class InstrumentedProgress(progress.ProgressTask):
 
2510
        class InstrumentedProgress(progress.DummyProgress):
2551
2511
 
2552
2512
            def __init__(self):
2553
 
                progress.ProgressTask.__init__(self)
 
2513
 
 
2514
                progress.DummyProgress.__init__(self)
2554
2515
                self.updates = []
2555
2516
 
2556
2517
            def update(self, msg=None, current=None, total=None):