~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# Authors:
4
4
#   Johan Rydberg <jrydberg@gnu.org>
2438
2438
        else:
2439
2439
            self.assertIdenticalVersionedFile(source, files)
2440
2440
 
 
2441
    def test_insert_record_stream_long_parent_chain_out_of_order(self):
 
2442
        """An out of order stream can either error or work."""
 
2443
        if not self.graph:
 
2444
            raise TestNotApplicable('ancestry info only relevant with graph.')
 
2445
        # Create a reasonably long chain of records based on each other, where
 
2446
        # most will be deltas.
 
2447
        source = self.get_versionedfiles('source')
 
2448
        parents = ()
 
2449
        keys = []
 
2450
        content = [('same same %d\n' % n) for n in range(500)]
 
2451
        for letter in 'abcdefghijklmnopqrstuvwxyz':
 
2452
            key = ('key-' + letter,)
 
2453
            if self.key_length == 2:
 
2454
                key = ('prefix',) + key
 
2455
            content.append('content for ' + letter + '\n')
 
2456
            source.add_lines(key, parents, content)
 
2457
            keys.append(key)
 
2458
            parents = (key,)
 
2459
        # Create a stream of these records, excluding the first record that the
 
2460
        # rest ultimately depend upon, and insert it into a new vf.
 
2461
        streams = []
 
2462
        for key in reversed(keys):
 
2463
            streams.append(source.get_record_stream([key], 'unordered', False))
 
2464
        deltas = chain(*streams[:-1])
 
2465
        files = self.get_versionedfiles()
 
2466
        try:
 
2467
            files.insert_record_stream(deltas)
 
2468
        except RevisionNotPresent:
 
2469
            # Must not have corrupted the file.
 
2470
            files.check()
 
2471
        else:
 
2472
            # Must only report either just the first key as a missing parent,
 
2473
            # no key as missing (for nodelta scenarios).
 
2474
            missing = set(files.get_missing_compression_parent_keys())
 
2475
            missing.discard(keys[0])
 
2476
            self.assertEqual(set(), missing)
 
2477
 
2441
2478
    def get_knit_delta_source(self):
2442
2479
        """Get a source that can produce a stream with knit delta records,
2443
2480
        regardless of this test's scenario.