69
69
repo.commit_write_group()
72
def add_commit(repo, revision_id, parent_ids):
74
repo.start_write_group()
75
inv = Inventory(revision_id=revision_id)
76
inv.root.revision = revision_id
77
root_id = inv.root.file_id
78
sha1 = repo.add_inventory(revision_id, inv, parent_ids)
79
vf = repo.weave_store.get_weave_or_empty(root_id,
80
repo.get_transaction())
81
vf.add_lines(revision_id, [], [])
82
rev = bzrlib.revision.Revision(timestamp=0,
84
committer="Foo Bar <foo@example.com>",
87
revision_id=revision_id)
88
rev.parent_ids = parent_ids
89
repo.add_revision(revision_id, rev)
90
repo.commit_write_group()
72
92
# an empty inventory with no revision for testing with.
73
93
# this is referenced by 'references_missing' to let us test
74
94
# that all the cached data is correctly converted into ghost links
78
98
repo.start_write_group()
79
99
repo.add_inventory('missing', inv, [])
80
inv = Inventory(revision_id='references_missing')
81
inv.root.revision = 'references_missing'
82
sha1 = repo.add_inventory('references_missing', inv, ['missing'])
83
rev = Revision(timestamp=0,
85
committer="Foo Bar <foo@example.com>",
88
revision_id='references_missing')
89
rev.parent_ids = ['missing']
90
repo.add_revision('references_missing', rev)
91
100
repo.commit_write_group()
102
add_commit(repo, 'references_missing', ['missing'])
94
104
# a inventory with no parents and the revision has parents..
96
106
repo = self.make_repository('inventory_one_ghost')
98
repo.start_write_group()
99
inv = Inventory(revision_id='ghost')
100
inv.root.revision = 'ghost'
101
sha1 = repo.add_inventory('ghost', inv, [])
102
rev = Revision(timestamp=0,
104
committer="Foo Bar <foo@example.com>",
108
rev.parent_ids = ['the_ghost']
109
repo.add_revision('ghost', rev)
110
repo.commit_write_group()
107
add_commit(repo, 'ghost', ['the_ghost'])
113
109
# a inventory with a ghost that can be corrected now.
114
110
t.copy_tree('inventory_one_ghost', 'inventory_ghost_present')
115
111
bzrdir_url = self.get_url('inventory_ghost_present')
116
112
bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
117
113
repo = bzrdir.open_repository()
119
repo.start_write_group()
120
inv = Inventory(revision_id='the_ghost')
121
inv.root.revision = 'the_ghost'
122
sha1 = repo.add_inventory('the_ghost', inv, [])
123
rev = Revision(timestamp=0,
125
committer="Foo Bar <foo@example.com>",
128
revision_id='the_ghost')
130
repo.add_revision('the_ghost', rev)
131
repo.commit_write_group()
114
add_commit(repo, 'the_ghost', [])
134
116
def checkEmptyReconcile(self, **kwargs):
135
117
"""Check a reconcile on an empty repository."""
212
194
repo.get_ancestry('references_missing'))
214
196
def check_missing_was_removed(self, repo):
215
backup = repo.control_weaves.get_weave('inventory.backup',
216
repo.get_transaction())
217
self.assertTrue('missing' in backup.versions())
197
if repo._reconcile_backsup_inventory:
198
backup = repo.control_weaves.get_weave('inventory.backup',
199
repo.get_transaction())
200
self.assertTrue('missing' in backup.versions())
218
201
self.assertRaises(errors.RevisionNotPresent,
219
202
repo.get_inventory, 'missing')
340
323
repo.start_write_group()
341
324
inv = Inventory(revision_id='wrong-secondary-parent')
342
325
inv.root.revision = 'wrong-secondary-parent'
326
if repo.supports_rich_root():
327
root_id = inv.root.file_id
328
vf = repo.weave_store.get_weave_or_empty(root_id,
329
repo.get_transaction())
330
vf.add_lines('wrong-secondary-parent', [], [])
343
331
sha1 = repo.add_inventory('wrong-secondary-parent', inv, ['1', '3', '2'])
344
332
rev = Revision(timestamp=0,