17
17
"""Helper classes for repository implementation tests."""
19
from cStringIO import StringIO
20
21
from bzrlib import (
22
24
revision as _mod_revision,
24
26
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
54
56
inv = inventory.Inventory(revision_id='revision-id')
55
57
inv.root.revision = 'revision-id'
56
repo.add_inventory('revision-id', inv, [])
58
inv_sha1 = repo.add_inventory('revision-id', inv, [])
59
if repo.supports_rich_root():
60
root_id = inv.root.file_id
61
vf = repo.weave_store.get_weave_or_empty(root_id,
62
repo.get_transaction())
63
vf.add_lines('revision-id', [], [])
57
64
revision = _mod_revision.Revision('revision-id',
58
65
committer='jrandom@example.com', timestamp=0,
59
inventory_sha1='', timezone=0, message='message', parent_ids=[])
60
repo.add_revision('revision-id',revision, inv)
66
inventory_sha1=inv_sha1, timezone=0, message='message',
68
# Manually add the revision text using the RevisionStore API, with
71
repo._revision_store._serializer.write_revision(revision, rev_tmp)
73
repo._revision_store.get_revision_file(repo.get_transaction()
74
).add_lines_with_ghosts(revision.revision_id,
76
osutils.split_lines(rev_tmp.read()))
62
78
repo.abort_write_group()
66
82
repo.commit_write_group()
69
# Change the knit index's record of the parents for 'revision-id' to
70
# claim it has a parent, 'incorrect-parent', that doesn't exist in this
73
86
self.addCleanup(repo.unlock)
74
rev_knit = repo._get_revision_vf()
75
index_cache = rev_knit._index._cache
76
cached_index_entry = list(index_cache['revision-id'])
77
cached_index_entry[4] = ['incorrect-parent']
78
index_cache['revision-id'] = tuple(cached_index_entry)