205
205
# does not must discard it, and when filling a ghost for a listed
206
206
# ghost must reconcile it
207
207
source = self.get_source()
209
source.has_ghost('a')
211
except NotImplementedError:
212
source_ghosts = False
213
208
target = self.get_target()
215
target.has_ghost('a')
217
except NotImplementedError:
218
target_ghosts = False
220
if not source_ghosts and not target_ghosts:
223
if source_ghosts and not target_ghosts:
224
# switch source and target so source is ghostless
228
source_ghosts = False
230
# now target always supports ghosts.
232
209
# try filling target with ghosts and filling in reverse -
233
target.add_lines_with_ghosts('notbase', ['base'], [])
211
target.add_lines_with_ghosts('notbase', ['base'], [])
212
except NotImplementedError:
213
# The target does not support ghosts; the test is irrelevant.
235
216
source.join(target)
236
217
except errors.RevisionNotPresent:
237
# can't join a ghost containing target onto a non-ghost supporting
239
self.assertFalse(source_ghosts)
242
self.assertTrue(source_ghosts)
243
219
# legacy apis should behave
244
220
self.assertEqual(['notbase'], source.get_ancestry(['notbase']))
245
self.assertEqual({'notbase':()}, source.get_graph())
246
221
self.assertFalse(source.has_version('base'))
247
222
# ghost data should have been preserved
248
223
self.assertEqual(['base', 'notbase'], source.get_ancestry_with_ghosts(['notbase']))
249
224
self.assertEqual(['base'], source.get_parents_with_ghosts('notbase'))
250
self.assertEqual({'notbase':('base',)}, source.get_parent_map(['notbase']))
251
self.assertEqual({'notbase':('base',)}, source.get_graph_with_ghosts())
252
self.assertTrue(source.has_ghost('base'))
225
self.assertEqual({'notbase':('base',)},
226
source.get_parent_map(source.versions()))
254
228
# if we add something that is fills out what is a ghost, then
255
229
# when joining into a ghost aware join it should flesh out the ghosts.
256
230
source.add_lines('base', [], [])
257
target.join(source, version_ids=['base'])
231
target.join(source, version_ids=['base'])
258
232
self.assertEqual(['base', 'notbase'], target.get_ancestry(['notbase']))
259
self.assertEqual({'notbase':('base',)}, target.get_parent_map(['notbase']))
260
233
self.assertEqual({'base':(),
261
234
'notbase':('base', ),
236
target.get_parent_map(target.versions()))
264
237
self.assertTrue(target.has_version('base'))
265
238
# we have _with_ghost apis to give us ghost information.
266
239
self.assertEqual(['base', 'notbase'], target.get_ancestry_with_ghosts(['notbase']))