~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Aaron Bentley
  • Date: 2006-02-28 18:56:52 UTC
  • mto: (147.4.30 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: abentley@panoramicfeedback.com-20060228185652-374bb521bcc8dc2d
Got imports working, via a big hammer

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import os
25
25
from bzrlib.plugins.bzrtools.baz_import import (import_version, revision_id, 
26
26
                                                cmd_baz_import)
27
 
from bzrlib.plugins.errors import NoTestResources
28
27
from bzrlib.errors import NoSuchRevision
29
28
import shutil
30
29
from StringIO import StringIO
210
209
        branch = Branch.open('output')
211
210
        self.assertEqual(branch.revision_history(),
212
211
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
213
 
        rev = branch.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
 
212
        rev = branch.repository.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
214
213
        # and again.
215
214
        import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'),
216
215
                       self.collect)
217
216
        branch2 = Branch.open('output2')
218
217
        self.assertEqual(branch.revision_history(), branch2.revision_history())
219
 
        rev2 = branch2.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
 
218
        rev2 = branch2.repository.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
220
219
        # they must be the same
221
220
        self.assertEqual(rev, rev2)
222
221
 
237
236
        self.assertEqual(branch.revision_history(),
238
237
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
239
238
                          self._baz._empty_tag_bzr])
240
 
        rev = branch.get_revision(self._baz._empty_tag_bzr)
 
239
        rev = branch.repository.get_revision(self._baz._empty_tag_bzr)
241
240
        # and again.
242
241
        import_version('output2', pybaz.Version(self._baz._empty_tag),
243
242
                       self.collect)
244
243
        branch2 = Branch.open('output2')
245
244
        self.assertEqual(branch.revision_history(), branch2.revision_history())
246
 
        rev2 = branch2.get_revision(self._baz._empty_tag_bzr)
 
245
        rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr)
247
246
        # they must be the same
248
247
        self.assertEqual(rev, rev2)
249
248
 
279
278
        self.assertEqual(branch.revision_history(), branch2.revision_history())
280
279
        self.assertNotEqual(branch.revision_history(), branch3.revision_history())
281
280
        # check revisions in the history.
282
 
        rev = branch.get_revision(self._baz._empty_merged_tag_bzr_base)
283
 
        rev2 = branch2.get_revision(self._baz._empty_merged_tag_bzr_base)
 
281
        rev = branch.repository.get_revision(self._baz._empty_merged_tag_bzr_base)
 
282
        rev2 = branch2.repository.get_revision(self._baz._empty_merged_tag_bzr_base)
284
283
        # they must be the same
285
284
        self.assertEqual(rev, rev2)
286
285
        # and we should get some expected values:
291
290
                         rev.parent_ids)
292
291
 
293
292
        # check next revisions in the history.
294
 
        rev = branch.get_revision(self._baz._empty_merged_tag_bzr)
295
 
        rev2 = branch2.get_revision(self._baz._empty_merged_tag_bzr)
 
293
        rev = branch.repository.get_revision(self._baz._empty_merged_tag_bzr)
 
294
        rev2 = branch2.repository.get_revision(self._baz._empty_merged_tag_bzr)
296
295
        # they must be the same
297
296
        self.assertEqual(rev, rev2)
298
297
        # and we should get some expected values:
334
333
        self.assertEqual(branch.revision_history(), branch2.revision_history())
335
334
        self.assertNotEqual(branch.revision_history(), branch3.revision_history())
336
335
        # check revisions in the history.
337
 
        rev = branch.get_revision(self._baz._empty_merged_tag_2_bzr_base)
338
 
        rev2 = branch2.get_revision(self._baz._empty_merged_tag_2_bzr_base)
 
336
        rev = branch.repository.get_revision(self._baz._empty_merged_tag_2_bzr_base)
 
337
        rev2 = branch2.repository.get_revision(self._baz._empty_merged_tag_2_bzr_base)
339
338
        # they must be the same
340
339
        self.assertEqual(rev, rev2)
341
340
        # and we should get some expected values:
344
343
        self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_2_bzr_base)
345
344
 
346
345
        # check next revisions in the history.
347
 
        rev = branch.get_revision(self._baz._empty_merged_tag_2_bzr)
348
 
        rev2 = branch2.get_revision(self._baz._empty_merged_tag_2_bzr)
 
346
        rev = branch.repository.get_revision(self._baz._empty_merged_tag_2_bzr)
 
347
        rev2 = branch2.repository.get_revision(self._baz._empty_merged_tag_2_bzr)
349
348
        # they must be the same
350
349
        self.assertEqual(rev, rev2)
351
350
        # and we should get some expected values:
369
368
        branch = Branch.open('output')
370
369
        self.assertEqual(branch.revision_history(),
371
370
                         [self._baz._import_symlink_bzr])
372
 
        rev = branch.get_revision(self._baz._import_symlink_bzr)
 
371
        rev = branch.repository.get_revision(self._baz._import_symlink_bzr)
373
372
        # and again.
374
373
        import_version('output2', pybaz.Version(self._baz._import_symlink),
375
374
                       self.collect)
376
375
        branch2 = Branch.open('output2')
377
376
        self.assertEqual(branch.revision_history(), branch2.revision_history())
378
 
        rev2 = branch2.get_revision(self._baz._import_symlink_bzr)
 
377
        rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr)
379
378
        # they must be the same
380
379
        self.assertEqual(rev, rev2)
381
380
 
385
384
        self.assertEqual(rev.revision_id, self._baz._import_symlink_bzr)
386
385
 
387
386
        # and we want the symlink alink with target 'missing-file-name'
388
 
        inv = branch.get_inventory(rev.revision_id)
 
387
        inv = branch.repository.get_inventory(rev.revision_id)
389
388
        self.assertEqual(inv.path2id('alink'), 'x_symlink_tag')
390
389
        entry = inv['x_symlink_tag']
391
390
        self.assertEqual(entry.kind, 'symlink')
401
400
        branch = Branch.open('output')
402
401
        self.assertEqual(branch.revision_history(),
403
402
                         [self._baz._missing_ancestor_bzr])
404
 
        rev = branch.get_revision(self._baz._missing_ancestor_bzr)
 
403
        rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
405
404
        # and again.
406
405
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
407
406
                       self.collect)
408
407
        branch2 = Branch.open('output2')
409
408
        self.assertEqual(branch.revision_history(), branch2.revision_history())
410
 
        rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
 
409
        rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
411
410
        # they must be the same
412
411
        self.assertEqual(rev, rev2)
413
412
 
419
418
        self.assertEqual(1, len(rev.parent_ids))
420
419
 
421
420
        # must NOT be able to get the merged evision
422
 
        self.assertRaises(NoSuchRevision, branch.get_revision, 
 
421
        self.assertRaises(NoSuchRevision, branch.repository.get_revision, 
423
422
                          self._baz._missing_import_bzr)
424
423
 
425
424
    def test_missing_ancestor_reusing_history(self):
434
433
        self.assertEqual(branch.revision_history(),
435
434
                         [self._baz._missing_import_bzr,
436
435
                          self._baz._missing_ancestor_bzr])
437
 
        rev = branch.get_revision(self._baz._missing_ancestor_bzr)
 
436
        rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
438
437
        # and again.
439
438
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
440
439
                       self.collect,
441
440
                       reuse_history_from=[self._baz._missing_import_imported])
442
441
        branch2 = Branch.open('output2')
443
442
        self.assertEqual(branch.revision_history(), branch2.revision_history())
444
 
        rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
 
443
        rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
445
444
        # they must be the same
446
445
        self.assertEqual(rev, rev2)
447
446
 
448
447
        # must be able to get the missing base revision
449
 
        branch.get_revision(self._baz._missing_import_bzr)
 
448
        branch.repository.get_revision(self._baz._missing_import_bzr)
450
449
 
451
450
        # and we should get some expected values:
452
451
        self.assertEqual(rev.committer, "Test User<test@example.org>")
468
467
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
469
468
                          self._baz._bad_id_tag_bzr_base,
470
469
                          self._baz._bad_id_tag_bzr])
471
 
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
472
 
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
470
        rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
 
471
        inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
473
472
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
474
473
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
475
474
 
499
498
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
500
499
                          self._baz._bad_id_tag_bzr_base,
501
500
                          self._baz._bad_id_tag_bzr])
502
 
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
503
 
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
501
        rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
 
502
        inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
504
503
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
505
504
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
506
505
 
531
530
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
532
531
                          self._baz._bad_id_tag_bzr_base,
533
532
                          self._baz._bad_id_tag_bzr])
534
 
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
535
 
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
533
        rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
 
534
        inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
536
535
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
537
536
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
538
537