132
132
altered by all revisions it contains, which means that it needs both
133
133
the inventory for any revision it has, and the inventories of all that
134
134
revision's parents.
136
However, we should also skip any revisions which are ghosts in the
136
to_repo = self.make_to_repository('to')
137
if not to_repo._format.supports_external_lookups:
139
if not self.repository_format_to.supports_external_lookups:
138
140
raise TestNotApplicable("Need stacking support in the target.")
139
141
builder = self.make_branch_builder('branch')
140
142
builder.start_series()
141
143
builder.build_snapshot('base', None, [
142
('add', ('', 'root-id', 'directory', ''))])
143
builder.build_snapshot('left', ['base'], [])
144
builder.build_snapshot('right', ['base'], [])
145
builder.build_snapshot('merge', ['left', 'right'], [])
144
('add', ('', 'root-id', 'directory', '')),
145
('add', ('file', 'file-id', 'file', 'content\n'))])
146
builder.build_snapshot('left', ['base'], [
147
('modify', ('file-id', 'left content\n'))])
148
builder.build_snapshot('right', ['base'], [
149
('modify', ('file-id', 'right content\n'))])
150
builder.build_snapshot('merge', ['left', 'right'], [
151
('modify', ('file-id', 'left and right content\n'))])
146
152
builder.finish_series()
147
153
branch = builder.get_branch()
148
154
repo = self.make_to_repository('trunk')
161
167
self.assertEqual(
162
168
set([('left',), ('right',), ('merge',)]),
163
169
unstacked_repo.inventories.keys())
170
# And the basis inventories have been copied correctly
172
self.addCleanup(trunk.unlock)
173
left_tree, right_tree = trunk.repository.revision_trees(
175
stacked_branch.lock_read()
176
self.addCleanup(stacked_branch.unlock)
178
stacked_right_tree) = stacked_branch.repository.revision_trees(
180
self.assertEqual(left_tree.inventory, stacked_left_tree.inventory)
181
self.assertEqual(right_tree.inventory, stacked_right_tree.inventory)
183
def test_fetch_across_stacking_boundary_ignores_ghost(self):
184
if not self.repository_format_to.supports_external_lookups:
185
raise TestNotApplicable("Need stacking support in the target.")
186
to_repo = self.make_to_repository('to')
187
builder = self.make_branch_builder('branch')
188
builder.start_series()
189
builder.build_snapshot('base', None, [
190
('add', ('', 'root-id', 'directory', '')),
191
('add', ('file', 'file-id', 'file', 'content\n'))])
192
builder.build_snapshot('second', ['base'], [
193
('modify', ('file-id', 'second content\n'))])
194
builder.build_snapshot('third', ['second', 'ghost'], [
195
('modify', ('file-id', 'third content\n'))])
196
builder.finish_series()
197
branch = builder.get_branch()
198
repo = self.make_to_repository('trunk')
199
trunk = repo.bzrdir.create_branch()
200
trunk.repository.fetch(branch.repository, 'second')
201
repo = self.make_to_repository('stacked')
202
stacked_branch = repo.bzrdir.create_branch()
203
stacked_branch.set_stacked_on_url(trunk.base)
204
stacked_branch.repository.fetch(branch.repository, 'third')
205
unstacked_repo = stacked_branch.bzrdir.open_repository()
206
unstacked_repo.lock_read()
207
self.addCleanup(unstacked_repo.unlock)
208
self.assertFalse(unstacked_repo.has_revision('second'))
209
self.assertFalse(unstacked_repo.has_revision('ghost'))
211
set([('second',), ('third',)]),
212
unstacked_repo.inventories.keys())
213
# And the basis inventories have been copied correctly
215
self.addCleanup(trunk.unlock)
216
second_tree = trunk.repository.revision_tree('second')
217
stacked_branch.lock_read()
218
self.addCleanup(stacked_branch.unlock)
219
stacked_second_tree = stacked_branch.repository.revision_tree('second')
220
self.assertEqual(second_tree.inventory, stacked_second_tree.inventory)
165
222
def test_fetch_missing_basis_text(self):
166
223
"""If fetching a delta, we should die if a basis is not present."""
276
333
to_repo = self.make_to_repository('to')
277
334
to_repo.fetch(from_tree.branch.repository)
278
335
recorded_inv_sha1 = to_repo.get_inventory_sha1('foo-id')
279
xml = to_repo.get_inventory_xml('foo-id')
280
computed_inv_sha1 = osutils.sha_string(xml)
337
self.addCleanup(to_repo.unlock)
338
stream = to_repo.inventories.get_record_stream([('foo-id',)],
340
bytes = stream.next().get_bytes_as('fulltext')
341
computed_inv_sha1 = osutils.sha_string(bytes)
281
342
self.assertEqual(computed_inv_sha1, recorded_inv_sha1)