211
229
result = [prefix + suffix for suffix in suffix_list]
213
236
# we loop over each key because that spreads the inserts across prefixes,
214
237
# which is how commit operates.
215
238
for prefix in prefixes:
216
result.append(files.add_lines(prefix + ('origin',), (),
239
result.append(files.add_lines(prefix + get_key('origin'), (),
217
240
['origin' + last_char]))
218
241
for prefix in prefixes:
219
result.append(files.add_lines(prefix + ('base',),
242
result.append(files.add_lines(prefix + get_key('base'),
220
243
get_parents([('origin',)]), ['base' + last_char]))
221
244
for prefix in prefixes:
222
result.append(files.add_lines(prefix + ('left',),
245
result.append(files.add_lines(prefix + get_key('left'),
223
246
get_parents([('base',)]),
224
247
['base\n', 'left' + last_char]))
225
248
if not left_only:
226
249
for prefix in prefixes:
227
result.append(files.add_lines(prefix + ('right',),
250
result.append(files.add_lines(prefix + get_key('right'),
228
251
get_parents([('base',)]),
229
252
['base\n', 'right' + last_char]))
230
253
for prefix in prefixes:
231
result.append(files.add_lines(prefix + ('merged',),
254
result.append(files.add_lines(prefix + get_key('merged'),
232
255
get_parents([('left',), ('right',)]),
233
256
['base\n', 'left\n', 'right\n', 'merged' + last_char]))
1487
1510
"""Each parameterised test can be constructed on a transport."""
1488
1511
files = self.get_versionedfiles()
1490
def get_diamond_files(self, files, trailing_eol=True, left_only=False):
1513
def get_diamond_files(self, files, trailing_eol=True, left_only=False,
1491
1515
return get_diamond_files(files, self.key_length,
1492
1516
trailing_eol=trailing_eol, nograph=not self.graph,
1493
left_only=left_only)
1517
left_only=left_only, nokeys=nokeys)
1495
1519
def test_add_lines_nostoresha(self):
1496
1520
"""When nostore_sha is supplied using old content raises."""
1544
1568
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1571
def test_add_lines_no_key_generates_chk_key(self):
1572
files = self.get_versionedfiles()
1573
# save code by using the stock data insertion helper.
1574
adds = self.get_diamond_files(files, nokeys=True)
1576
# We can only validate the first 2 elements returned from add_lines.
1578
self.assertEqual(3, len(add))
1579
results.append(add[:2])
1580
if self.key_length == 1:
1582
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1583
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1584
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1585
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1586
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1588
# Check the added items got CHK keys.
1589
self.assertEqual(set([
1590
('sha1:00e364d235126be43292ab09cb4686cf703ddc17',),
1591
('sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44',),
1592
('sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1',),
1593
('sha1:a8478686da38e370e32e42e8a0c220e33ee9132f',),
1594
('sha1:ed8bce375198ea62444dc71952b22cfc2b09226d',),
1597
elif self.key_length == 2:
1599
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1600
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1601
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1602
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1603
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1604
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1605
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1606
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1607
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23),
1608
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1610
# Check the added items got CHK keys.
1611
self.assertEqual(set([
1612
('FileA', 'sha1:00e364d235126be43292ab09cb4686cf703ddc17'),
1613
('FileA', 'sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44'),
1614
('FileA', 'sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1'),
1615
('FileA', 'sha1:a8478686da38e370e32e42e8a0c220e33ee9132f'),
1616
('FileA', 'sha1:ed8bce375198ea62444dc71952b22cfc2b09226d'),
1617
('FileB', 'sha1:00e364d235126be43292ab09cb4686cf703ddc17'),
1618
('FileB', 'sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44'),
1619
('FileB', 'sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1'),
1620
('FileB', 'sha1:a8478686da38e370e32e42e8a0c220e33ee9132f'),
1621
('FileB', 'sha1:ed8bce375198ea62444dc71952b22cfc2b09226d'),
1547
1625
def test_empty_lines(self):
1548
1626
"""Empty files can be stored."""
1549
1627
f = self.get_versionedfiles()
1584
1662
'knit-ft', 'knit-delta', 'chunked', 'fulltext',
1585
1663
'knit-annotated-ft-gz', 'knit-annotated-delta-gz', 'knit-ft-gz',
1586
1664
'knit-delta-gz',
1587
'knit-delta-closure', 'knit-delta-closure-ref'])
1665
'knit-delta-closure', 'knit-delta-closure-ref',
1666
'groupcompress-block', 'groupcompress-block-ref'])
1589
1668
def capture_stream(self, f, entries, on_seen, parents):
1590
1669
"""Capture a stream for testing."""
1591
1670
for factory in entries:
1592
1671
on_seen(factory.key)
1593
1672
self.assertValidStorageKind(factory.storage_kind)
1594
self.assertEqual(f.get_sha1s([factory.key])[factory.key],
1673
if factory.sha1 is not None:
1674
self.assertEqual(f.get_sha1s([factory.key])[factory.key],
1596
1676
self.assertEqual(parents[factory.key], factory.parents)
1597
1677
self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),