~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/interversionedfile_implementations/test_join.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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()
208
 
        try:
209
 
            source.has_ghost('a')
210
 
            source_ghosts = True
211
 
        except NotImplementedError:
212
 
            source_ghosts = False
213
208
        target = self.get_target()
214
 
        try:
215
 
            target.has_ghost('a')
216
 
            target_ghosts = True
217
 
        except NotImplementedError:
218
 
            target_ghosts = False
219
 
 
220
 
        if not source_ghosts and not target_ghosts:
221
 
            # nothing to do
222
 
            return
223
 
        if source_ghosts and not target_ghosts:
224
 
            # switch source and target so source is ghostless
225
 
            t = source
226
 
            source = target
227
 
            target = t
228
 
            source_ghosts = False
229
 
            target_ghosts = True
230
 
        # now target always supports ghosts.
231
 
 
232
209
        # try filling target with ghosts and filling in reverse -  
233
 
        target.add_lines_with_ghosts('notbase', ['base'], [])
 
210
        try:
 
211
            target.add_lines_with_ghosts('notbase', ['base'], [])
 
212
        except NotImplementedError:
 
213
            # The target does not support ghosts; the test is irrelevant.
 
214
            return
234
215
        try:
235
216
            source.join(target)
236
217
        except errors.RevisionNotPresent:
237
 
            # can't join a ghost containing target onto a non-ghost supporting
238
 
            # source.
239
 
            self.assertFalse(source_ghosts)
240
218
            return
241
 
        else:
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()))
253
227
 
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', ),
262
235
                          },
263
 
                         target.get_graph())
 
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']))
268
241
        self.assertEqual({'base':(),
269
242
                          'notbase':('base',),
270
243
                          },
271
 
                         target.get_graph_with_ghosts())
272
 
        self.assertFalse(target.has_ghost('base'))
 
244
            source.get_parent_map(source.versions()))
273
245
 
274
246
    def test_restricted_join_into_empty(self):
275
247
        # joining into an empty versioned file with a version_ids list