734
734
# the ordering here is to make a tree so that dumb searches have
735
735
# more changes to muck up.
737
class InstrumentedProgress(progress.ProgressTask):
737
class InstrumentedProgress(progress.DummyProgress):
739
739
def __init__(self):
740
progress.ProgressTask.__init__(self)
741
progress.DummyProgress.__init__(self)
741
742
self.updates = []
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))
1475
1476
def get_simple_key(self, suffix):
1580
1581
# All texts should be output.
1581
1582
self.assertEqual(set(keys), seen)
1583
def test_clear_cache(self):
1584
files = self.get_versionedfiles()
1587
1584
def test_construct(self):
1588
1585
"""Each parameterised test can be constructed on a transport."""
1589
1586
files = self.get_versionedfiles()
1760
1757
self.assertIsInstance(kg, _mod_graph.KnownGraph)
1761
1758
self.assertEqual([key_a, key_b, key_c], list(kg.topo_sort()))
1763
def test_known_graph_with_fallbacks(self):
1764
f = self.get_versionedfiles('files')
1766
raise TestNotApplicable('ancestry info only relevant with graph.')
1767
if getattr(f, 'add_fallback_versioned_files', None) is None:
1768
raise TestNotApplicable("%s doesn't support fallbacks"
1769
% (f.__class__.__name__,))
1770
key_a = self.get_simple_key('a')
1771
key_b = self.get_simple_key('b')
1772
key_c = self.get_simple_key('c')
1773
# A only in fallback
1778
g = self.get_versionedfiles('fallback')
1779
g.add_lines(key_a, [], ['\n'])
1780
f.add_fallback_versioned_files(g)
1781
f.add_lines(key_b, [key_a], ['\n'])
1782
f.add_lines(key_c, [key_a, key_b], ['\n'])
1783
kg = f.get_known_graph_ancestry([key_c])
1784
self.assertEqual([key_a, key_b, key_c], list(kg.topo_sort()))
1786
1760
def test_get_record_stream_empty(self):
1787
1761
"""An empty stream can be requested without error."""
1788
1762
f = self.get_versionedfiles()
2438
2412
self.assertIdenticalVersionedFile(source, files)
2440
def test_insert_record_stream_long_parent_chain_out_of_order(self):
2441
"""An out of order stream can either error or work."""
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')
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)
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.
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()
2466
files.insert_record_stream(deltas)
2467
except RevisionNotPresent:
2468
# Must not have corrupted the file.
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)
2477
2414
def get_knit_delta_source(self):
2478
2415
"""Get a source that can produce a stream with knit delta records,
2479
2416
regardless of this test's scenario.
2547
2484
# the ordering here is to make a tree so that dumb searches have
2548
2485
# more changes to muck up.
2550
class InstrumentedProgress(progress.ProgressTask):
2487
class InstrumentedProgress(progress.DummyProgress):
2552
2489
def __init__(self):
2553
progress.ProgressTask.__init__(self)
2491
progress.DummyProgress.__init__(self)
2554
2492
self.updates = []
2556
2494
def update(self, msg=None, current=None, total=None):