38
from bzrlib.branchbuilder import BranchBuilder
37
39
from bzrlib.btree_index import BTreeBuilder, BTreeGraphIndex
38
from bzrlib.index import GraphIndex
40
from bzrlib.index import GraphIndex, InMemoryGraphIndex
39
41
from bzrlib.repository import RepositoryFormat
42
from bzrlib.smart import server
40
43
from bzrlib.tests import (
42
45
TestCaseWithTransport,
44
49
from bzrlib.transport import (
53
from bzrlib.transport.memory import MemoryServer
47
54
from bzrlib import (
53
62
revision as _mod_revision,
243
253
tree = control.create_workingtree()
244
254
tree.add(['foo'], ['Foo:Bar'], ['file'])
245
255
tree.put_file_bytes_non_atomic('Foo:Bar', 'content\n')
247
tree.commit('first post', rev_id='first')
248
except errors.IllegalPath:
249
if sys.platform != 'win32':
251
self.knownFailure('Foo:Bar cannot be used as a file-id on windows'
256
tree.commit('first post', rev_id='first')
254
257
self.assertEqualDiff(
255
258
'# bzr weave file v5\n'
466
469
# Arguably, the deserialise_inventory should detect a mismatch, and
467
470
# raise an error, rather than silently using one revision_id over the
469
self.assertRaises(AssertionError, repo._deserialise_inventory,
472
self.assertRaises(AssertionError, repo.deserialise_inventory,
470
473
'test-rev-id', inv_xml)
471
inv = repo._deserialise_inventory('other-rev-id', inv_xml)
474
inv = repo.deserialise_inventory('other-rev-id', inv_xml)
472
475
self.assertEqual('other-rev-id', inv.root.revision)
474
477
def test_supports_external_lookups(self):
679
682
self.assertFalse(repo._format.supports_external_lookups)
682
class Test2a(tests.TestCaseWithMemoryTransport):
684
def test_fetch_combines_groups(self):
685
builder = self.make_branch_builder('source', format='2a')
686
builder.start_series()
687
builder.build_snapshot('1', None, [
688
('add', ('', 'root-id', 'directory', '')),
689
('add', ('file', 'file-id', 'file', 'content\n'))])
690
builder.build_snapshot('2', ['1'], [
691
('modify', ('file-id', 'content-2\n'))])
692
builder.finish_series()
693
source = builder.get_branch()
694
target = self.make_repository('target', format='2a')
695
target.fetch(source.repository)
697
self.addCleanup(target.unlock)
698
details = target.texts._index.get_build_details(
699
[('file-id', '1',), ('file-id', '2',)])
700
file_1_details = details[('file-id', '1')]
701
file_2_details = details[('file-id', '2')]
702
# The index, and what to read off disk, should be the same for both
703
# versions of the file.
704
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
706
def test_fetch_combines_groups(self):
707
builder = self.make_branch_builder('source', format='2a')
708
builder.start_series()
709
builder.build_snapshot('1', None, [
710
('add', ('', 'root-id', 'directory', '')),
711
('add', ('file', 'file-id', 'file', 'content\n'))])
712
builder.build_snapshot('2', ['1'], [
713
('modify', ('file-id', 'content-2\n'))])
714
builder.finish_series()
715
source = builder.get_branch()
716
target = self.make_repository('target', format='2a')
717
target.fetch(source.repository)
719
self.addCleanup(target.unlock)
720
details = target.texts._index.get_build_details(
721
[('file-id', '1',), ('file-id', '2',)])
722
file_1_details = details[('file-id', '1')]
723
file_2_details = details[('file-id', '2')]
724
# The index, and what to read off disk, should be the same for both
725
# versions of the file.
726
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
685
class Test2a(TestCaseWithTransport):
728
687
def test_fetch_combines_groups(self):
729
688
builder = self.make_branch_builder('source', format='2a')
752
711
self.assertTrue(repo._format.pack_compresses)
754
713
def test_inventories_use_chk_map_with_parent_base_dict(self):
755
tree = self.make_branch_and_memory_tree('repo', format="2a")
757
tree.add([''], ['TREE_ROOT'])
714
tree = self.make_branch_and_tree('repo', format="2a")
758
715
revid = tree.commit("foo")
761
717
self.addCleanup(tree.unlock)
762
718
inv = tree.branch.repository.get_inventory(revid)
771
727
# at 20 unchanged commits, chk pages are packed that are split into
772
728
# two groups such that the new pack being made doesn't have all its
773
729
# pages in the source packs (though they are in the repository).
774
# Use a memory backed repository, we don't need to hit disk for this
775
tree = self.make_branch_and_memory_tree('tree', format='2a')
777
self.addCleanup(tree.unlock)
778
tree.add([''], ['TREE_ROOT'])
730
tree = self.make_branch_and_tree('tree', format='2a')
779
731
for pos in range(20):
780
732
tree.commit(str(pos))
782
734
def test_pack_with_hint(self):
783
tree = self.make_branch_and_memory_tree('tree', format='2a')
785
self.addCleanup(tree.unlock)
786
tree.add([''], ['TREE_ROOT'])
735
tree = self.make_branch_and_tree('tree', format='2a')
787
736
# 1 commit to leave untouched
789
738
to_keep = tree.branch.repository._pack_collection.names()