553
553
builder = self.make_branch_builder('source', format='2a')
554
554
builder.start_series()
555
555
builder.build_snapshot(None, [
556
('add', ('', 'root-id', 'directory', '')),
557
('add', ('file', 'file-id', 'file', 'content\n'))],
559
builder.build_snapshot(['1'], [
560
('modify', ('file-id', 'content-2\n'))],
562
builder.finish_series()
563
source = builder.get_branch()
564
target = self.make_repository('target', format='2a')
565
target.fetch(source.repository)
567
self.addCleanup(target.unlock)
568
details = target.texts._index.get_build_details(
569
[('file-id', '1',), ('file-id', '2',)])
570
file_1_details = details[('file-id', '1')]
571
file_2_details = details[('file-id', '2')]
572
# The index, and what to read off disk, should be the same for both
573
# versions of the file.
574
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
576
def test_fetch_combines_groups(self):
577
builder = self.make_branch_builder('source', format='2a')
578
builder.start_series()
579
builder.build_snapshot(None, [
580
('add', ('', 'root-id', 'directory', '')),
581
('add', ('file', 'file-id', 'file', 'content\n'))],
583
builder.build_snapshot(['1'], [
584
('modify', ('file-id', 'content-2\n'))],
586
builder.finish_series()
587
source = builder.get_branch()
588
target = self.make_repository('target', format='2a')
589
target.fetch(source.repository)
591
self.addCleanup(target.unlock)
592
details = target.texts._index.get_build_details(
593
[('file-id', '1',), ('file-id', '2',)])
594
file_1_details = details[('file-id', '1')]
595
file_2_details = details[('file-id', '2')]
596
# The index, and what to read off disk, should be the same for both
597
# versions of the file.
598
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
600
def test_fetch_combines_groups(self):
601
builder = self.make_branch_builder('source', format='2a')
602
builder.start_series()
603
builder.build_snapshot(None, [
604
('add', ('', 'root-id', 'directory', '')),
605
('add', ('file', 'file-id', 'file', 'content\n'))],
607
builder.build_snapshot(['1'], [
608
('modify', ('file-id', 'content-2\n'))],
610
builder.finish_series()
611
source = builder.get_branch()
612
target = self.make_repository('target', format='2a')
613
target.fetch(source.repository)
615
self.addCleanup(target.unlock)
616
details = target.texts._index.get_build_details(
617
[('file-id', '1',), ('file-id', '2',)])
618
file_1_details = details[('file-id', '1')]
619
file_2_details = details[('file-id', '2')]
556
('add', ('', b'root-id', 'directory', '')),
557
('add', ('file', b'file-id', 'file', 'content\n'))],
559
builder.build_snapshot(['1'], [
560
('modify', (b'file-id', 'content-2\n'))],
562
builder.finish_series()
563
source = builder.get_branch()
564
target = self.make_repository('target', format='2a')
565
target.fetch(source.repository)
567
self.addCleanup(target.unlock)
568
details = target.texts._index.get_build_details(
569
[(b'file-id', '1',), (b'file-id', '2',)])
570
file_1_details = details[(b'file-id', '1')]
571
file_2_details = details[(b'file-id', '2')]
572
# The index, and what to read off disk, should be the same for both
573
# versions of the file.
574
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
576
def test_fetch_combines_groups(self):
577
builder = self.make_branch_builder('source', format='2a')
578
builder.start_series()
579
builder.build_snapshot(None, [
580
('add', ('', b'root-id', 'directory', '')),
581
('add', ('file', b'file-id', 'file', 'content\n'))],
583
builder.build_snapshot([b'1'], [
584
('modify', (b'file-id', 'content-2\n'))],
586
builder.finish_series()
587
source = builder.get_branch()
588
target = self.make_repository('target', format='2a')
589
target.fetch(source.repository)
591
self.addCleanup(target.unlock)
592
details = target.texts._index.get_build_details(
593
[(b'file-id', '1',), (b'file-id', '2',)])
594
file_1_details = details[(b'file-id', '1')]
595
file_2_details = details[(b'file-id', '2')]
596
# The index, and what to read off disk, should be the same for both
597
# versions of the file.
598
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
600
def test_fetch_combines_groups(self):
601
builder = self.make_branch_builder('source', format='2a')
602
builder.start_series()
603
builder.build_snapshot(None, [
604
('add', ('', b'root-id', 'directory', '')),
605
('add', ('file', b'file-id', 'file', 'content\n'))],
607
builder.build_snapshot([b'1'], [
608
('modify', (b'file-id', 'content-2\n'))],
610
builder.finish_series()
611
source = builder.get_branch()
612
target = self.make_repository('target', format='2a')
613
target.fetch(source.repository)
615
self.addCleanup(target.unlock)
616
details = target.texts._index.get_build_details(
617
[(b'file-id', '1',), (b'file-id', '2',)])
618
file_1_details = details[(b'file-id', '1')]
619
file_2_details = details[(b'file-id', '2')]
620
620
# The index, and what to read off disk, should be the same for both
621
621
# versions of the file.
622
622
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
694
694
# We have to build a fairly large tree, so that we are sure the chk
695
695
# pages will have split into multiple pages.
696
entries = [('add', ('', 'a-root-id', 'directory', None))]
696
entries = [('add', ('', b'a-root-id', 'directory', None))]
697
697
for i in 'abcdefghijklmnopqrstuvwxyz123456789':
698
698
for j in 'abcdefghijklmnopqrstuvwxyz123456789':
700
fid = fname.encode('utf-8') + b'-id'
701
701
content = 'content for %s\n' % (fname,)
702
702
entries.append(('add', (fname, fid, 'file', content)))
703
703
source_builder.start_series()
704
source_builder.build_snapshot(None, entries, revision_id='rev-1')
704
source_builder.build_snapshot(None, entries, revision_id=b'rev-1')
705
705
# Now change a few of them, so we get a few new pages for the second
707
source_builder.build_snapshot(['rev-1'], [
708
('modify', ('aa-id', 'new content for aa-id\n')),
709
('modify', ('cc-id', 'new content for cc-id\n')),
710
('modify', ('zz-id', 'new content for zz-id\n')),
711
], revision_id='rev-2')
707
source_builder.build_snapshot([b'rev-1'], [
708
('modify', (b'aa-id', 'new content for aa-id\n')),
709
('modify', (b'cc-id', 'new content for cc-id\n')),
710
('modify', (b'zz-id', 'new content for zz-id\n')),
711
], revision_id=b'rev-2')
712
712
source_builder.finish_series()
713
713
source_branch = source_builder.get_branch()
714
714
source_branch.lock_read()