/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/helpers.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-14 08:20:26 UTC
  • mfrom: (2974 +trunk)
  • mto: (2990.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2991.
  • Revision ID: v.ladeuil+lp@free.fr-20071114082026-4d27f52n5r0t82rw
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Helper classes for repository implementation tests."""
18
18
 
 
19
from cStringIO import StringIO
19
20
 
20
21
from bzrlib import (
21
22
    inventory,
 
23
    osutils,
22
24
    revision as _mod_revision,
23
25
    )
24
26
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
53
55
        try:
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',
 
67
                parent_ids=[])
 
68
            # Manually add the revision text using the RevisionStore API, with
 
69
            # bad parents.
 
70
            rev_tmp = StringIO()
 
71
            repo._revision_store._serializer.write_revision(revision, rev_tmp)
 
72
            rev_tmp.seek(0)
 
73
            repo._revision_store.get_revision_file(repo.get_transaction()
 
74
                ).add_lines_with_ghosts(revision.revision_id,
 
75
                ['incorrect-parent'],
 
76
                osutils.split_lines(rev_tmp.read()))
61
77
        except:
62
78
            repo.abort_write_group()
63
79
            repo.unlock()
66
82
            repo.commit_write_group()
67
83
            repo.unlock()
68
84
 
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
71
 
        # knit at all.
72
85
        repo.lock_write()
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)
79
87
        return repo
80
88