~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Aaron Bentley
  • Date: 2005-10-28 03:01:02 UTC
  • mfrom: (147.4.13)
  • mto: (147.4.24 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: aaron.bentley@utoronto.ca-20051028030102-eead1e484007de74
Merged lifeless

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
        # tag into the kept archive
158
158
        pybaz.Revision(self._missing_import + '--base-0').make_continuation(
159
159
            pybaz.Version(self._missing_ancestor))
 
160
 
 
161
        # make an import for testing history-reuse logic.
 
162
        def collect(text):
 
163
            pass
 
164
        # note the use of a namespace layout here.
 
165
        self._missing_import_imported = os.path.join(self._tmpdir, 
 
166
                                                     'archivegone-bzr')
 
167
        os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr'))
 
168
        os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c'))
 
169
        import_version(os.path.join(self._tmpdir, 'archivegone-bzr', 
 
170
                                    'c', 'import'),
 
171
                       pybaz.Version(self._missing_import),
 
172
                       collect)
160
173
        # and make it inaccessible
161
174
        pybaz.Archive('demo-gone@DONOTUSE').unregister()
162
175
 
271
284
        self.assertEqual(rev.committer, "Test User<test@example.org>")
272
285
        self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0")
273
286
        self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_bzr_base)
 
287
        self.assertEqual(['Arch-1:demo@DONOTUSE%c--import--0--base-0'],
 
288
                         rev.parent_ids)
274
289
 
275
290
        # check next revisions in the history.
276
291
        rev = branch.get_revision(self._baz._empty_merged_tag_bzr)
404
419
        self.assertRaises(NoSuchRevision, branch.get_revision, 
405
420
                          self._baz._missing_import_bzr)
406
421
 
 
422
    def test_missing_ancestor_reusing_history(self):
 
423
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
 
424
                       self.collect,
 
425
                       reuse_history_from=[self._baz._missing_import_imported])
 
426
        # expected results:
 
427
        # one commits, no files, revision identifiers of 
 
428
        # 'demo-gone@DONOTUSE%c--import--0--base-0' and 
 
429
        # 'demo@DONOTUSE%c--gone--0--base-0'
 
430
        branch = Branch.open('output')
 
431
        self.assertEqual(branch.revision_history(),
 
432
                         [self._baz._missing_import_bzr,
 
433
                          self._baz._missing_ancestor_bzr])
 
434
        rev = branch.get_revision(self._baz._missing_ancestor_bzr)
 
435
        # and again.
 
436
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
 
437
                       self.collect,
 
438
                       reuse_history_from=[self._baz._missing_import_imported])
 
439
        branch2 = Branch.open('output2')
 
440
        self.assertEqual(branch.revision_history(), branch2.revision_history())
 
441
        rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
 
442
        # they must be the same
 
443
        self.assertEqual(rev, rev2)
 
444
 
 
445
        # must be able to get the missing base revision
 
446
        branch.get_revision(self._baz._missing_import_bzr)
 
447
 
 
448
        # and we should get some expected values:
 
449
        self.assertEqual(rev.committer, "Test User<test@example.org>")
 
450
        self.assertEqual(rev.message, "tag of demo-gone@DONOTUSE/c--import--0--base-0")
 
451
        self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr)
 
452
        self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr)
 
453
        self.assertEqual(1, len(rev.parent_ids))
 
454
 
407
455
    def test_bad_file_id(self):
408
456
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
409
457
                       self.collect)
595
643
        command = cmd_baz_import()
596
644
        command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
597
645
        command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
 
646
        
 
647
    def test_accepts_reuse_history(self):
 
648
        self.make_import('c--0')
 
649
        self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
 
650
                     'demo@DONOTUSE', '.', '.')
 
651
        
 
652
    def test_does_not_need_reuse_history(self):
 
653
        self.make_import('c--0')
 
654
        self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
 
655
                     'demo@DONOTUSE')