211
214
result = [prefix + suffix for suffix in suffix_list]
213
221
# we loop over each key because that spreads the inserts across prefixes,
214
222
# which is how commit operates.
215
223
for prefix in prefixes:
216
result.append(files.add_lines(prefix + ('origin',), (),
224
result.append(files.add_lines(prefix + get_key('origin'), (),
217
225
['origin' + last_char]))
218
226
for prefix in prefixes:
219
result.append(files.add_lines(prefix + ('base',),
227
result.append(files.add_lines(prefix + get_key('base'),
220
228
get_parents([('origin',)]), ['base' + last_char]))
221
229
for prefix in prefixes:
222
result.append(files.add_lines(prefix + ('left',),
230
result.append(files.add_lines(prefix + get_key('left'),
223
231
get_parents([('base',)]),
224
232
['base\n', 'left' + last_char]))
225
233
if not left_only:
226
234
for prefix in prefixes:
227
result.append(files.add_lines(prefix + ('right',),
235
result.append(files.add_lines(prefix + get_key('right'),
228
236
get_parents([('base',)]),
229
237
['base\n', 'right' + last_char]))
230
238
for prefix in prefixes:
231
result.append(files.add_lines(prefix + ('merged',),
239
result.append(files.add_lines(prefix + get_key('merged'),
232
240
get_parents([('left',), ('right',)]),
233
241
['base\n', 'left\n', 'right\n', 'merged' + last_char]))
1487
1495
"""Each parameterised test can be constructed on a transport."""
1488
1496
files = self.get_versionedfiles()
1490
def get_diamond_files(self, files, trailing_eol=True, left_only=False):
1498
def get_diamond_files(self, files, trailing_eol=True, left_only=False,
1491
1500
return get_diamond_files(files, self.key_length,
1492
1501
trailing_eol=trailing_eol, nograph=not self.graph,
1493
left_only=left_only)
1502
left_only=left_only, nokeys=nokeys)
1495
1504
def test_add_lines_nostoresha(self):
1496
1505
"""When nostore_sha is supplied using old content raises."""
1544
1553
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1556
def test_add_lines_no_key_generates_chk_key(self):
1557
files = self.get_versionedfiles()
1558
# save code by using the stock data insertion helper.
1559
adds = self.get_diamond_files(files, nokeys=True)
1561
# We can only validate the first 2 elements returned from add_lines.
1563
self.assertEqual(3, len(add))
1564
results.append(add[:2])
1565
if self.key_length == 1:
1567
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1568
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1569
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1570
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1571
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1573
# Check the added items got CHK keys.
1574
self.assertEqual(set([
1575
('sha1:00e364d235126be43292ab09cb4686cf703ddc17',),
1576
('sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44',),
1577
('sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1',),
1578
('sha1:a8478686da38e370e32e42e8a0c220e33ee9132f',),
1579
('sha1:ed8bce375198ea62444dc71952b22cfc2b09226d',),
1582
elif self.key_length == 2:
1584
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1585
('00e364d235126be43292ab09cb4686cf703ddc17', 7),
1586
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1587
('51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44', 5),
1588
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1589
('a8478686da38e370e32e42e8a0c220e33ee9132f', 10),
1590
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1591
('9ef09dfa9d86780bdec9219a22560c6ece8e0ef1', 11),
1592
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23),
1593
('ed8bce375198ea62444dc71952b22cfc2b09226d', 23)],
1595
# Check the added items got CHK keys.
1596
self.assertEqual(set([
1597
('FileA', 'sha1:00e364d235126be43292ab09cb4686cf703ddc17'),
1598
('FileA', 'sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44'),
1599
('FileA', 'sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1'),
1600
('FileA', 'sha1:a8478686da38e370e32e42e8a0c220e33ee9132f'),
1601
('FileA', 'sha1:ed8bce375198ea62444dc71952b22cfc2b09226d'),
1602
('FileB', 'sha1:00e364d235126be43292ab09cb4686cf703ddc17'),
1603
('FileB', 'sha1:51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44'),
1604
('FileB', 'sha1:9ef09dfa9d86780bdec9219a22560c6ece8e0ef1'),
1605
('FileB', 'sha1:a8478686da38e370e32e42e8a0c220e33ee9132f'),
1606
('FileB', 'sha1:ed8bce375198ea62444dc71952b22cfc2b09226d'),
1547
1610
def test_empty_lines(self):
1548
1611
"""Empty files can be stored."""
1549
1612
f = self.get_versionedfiles()