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