~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-24 00:08:03 UTC
  • mfrom: (147.4.5)
  • mto: (147.4.12)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: aaron.bentley@utoronto.ca-20051024000803-0e9b59dee42d0460
Merge lifeless

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        tree.commit(msg)
95
95
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
96
96
 
 
97
        self._bad_id_tag = 'demo@DONOTUSE/c--bad-id--0'
 
98
        self._bad_id_tag_bzr_base = revision_id(self._bad_id_tag + '--base-0')
 
99
        self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1')
 
100
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
 
101
            pybaz.Version(self._bad_id_tag))
 
102
        tree = pybaz.Revision(self._bad_id_tag + '--base-0').get(
 
103
            os.path.join(self._tmpdir, 'tree'))
 
104
        from bzrlib.plugins.bzrtools.baz_import import add_file
 
105
        add_file(os.path.join(self._tmpdir,'tree/path'), 'text', 'this_id/needs%escaping')
 
106
        msg = tree.log_message()
 
107
        msg["summary"] = "commit something which needs escaping."
 
108
        tree.commit(msg)
 
109
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
 
110
 
97
111
        self.make_import_symlink()
98
112
        self.make_missing_ancestor()
99
113
 
390
404
        self.assertRaises(NoSuchRevision, branch.get_revision, 
391
405
                          self._baz._missing_import_bzr)
392
406
 
 
407
    def test_bad_file_id(self):
 
408
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
409
                       self.collect)
 
410
        # expected results:
 
411
        # three commits, one files, revision identifiers of 
 
412
        # 'demo@DONOTUSE_c--import--0--base-0' ,
 
413
        # 'demo@DONOTUSE/c--bad-id--0--base-0' ,
 
414
        # ''demo@DONOTUSE/c--bad-id--0--patch-1'
 
415
        branch = Branch.open('output')
 
416
        self.assertEqual(branch.revision_history(),
 
417
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
 
418
                          self._baz._bad_id_tag_bzr_base,
 
419
                          self._baz._bad_id_tag_bzr])
 
420
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
 
421
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
422
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
 
423
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
 
424
 
 
425
    def test_appending_revisions_already_present(self):
 
426
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
427
                       self.collect, max_count=2)
 
428
        # expected results:
 
429
        # three commits, one files, revision identifiers of 
 
430
        # 'demo@DONOTUSE_c--import--0--base-0' ,
 
431
        # 'demo@DONOTUSE/c--bad-id--0--base-0' ,
 
432
        # ''demo@DONOTUSE/c--bad-id--0--patch-1'
 
433
        branch = Branch.open('output')
 
434
        self.assertEqual(branch.revision_history(),
 
435
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
 
436
                          self._baz._bad_id_tag_bzr_base])
 
437
        branch.set_revision_history(
 
438
            ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
 
439
        del branch
 
440
        branch = Branch.open('output')
 
441
        self.assertEqual(branch.revision_history(),
 
442
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
 
443
        del branch
 
444
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
445
                       self.collect)
 
446
        branch = Branch.open('output')
 
447
        self.assertEqual(branch.revision_history(),
 
448
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
 
449
                          self._baz._bad_id_tag_bzr_base,
 
450
                          self._baz._bad_id_tag_bzr])
 
451
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
 
452
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
453
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
 
454
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
 
455
 
 
456
    def test_appending_revisions_all_already_present(self):
 
457
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
458
                       self.collect)
 
459
        # expected results:
 
460
        # three commits, one files, revision identifiers of 
 
461
        # 'demo@DONOTUSE_c--import--0--base-0' ,
 
462
        # 'demo@DONOTUSE/c--bad-id--0--base-0' ,
 
463
        # ''demo@DONOTUSE/c--bad-id--0--patch-1'
 
464
        branch = Branch.open('output')
 
465
        self.assertEqual(branch.revision_history(),
 
466
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
 
467
                          self._baz._bad_id_tag_bzr_base,
 
468
                          self._baz._bad_id_tag_bzr])
 
469
        branch.set_revision_history(
 
470
            ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
 
471
        del branch
 
472
        branch = Branch.open('output')
 
473
        self.assertEqual(branch.revision_history(),
 
474
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
 
475
        del branch
 
476
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
477
                       self.collect)
 
478
        branch = Branch.open('output')
 
479
        self.assertEqual(branch.revision_history(),
 
480
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
 
481
                          self._baz._bad_id_tag_bzr_base,
 
482
                          self._baz._bad_id_tag_bzr])
 
483
        rev = branch.get_revision(self._baz._bad_id_tag_bzr)
 
484
        inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
 
485
        self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
 
486
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
 
487
 
393
488
 
394
489
class TestNamespacePrevious(TestCase):
395
490
 
439
534
                         map_namespace(pybaz.Version('%s--0.1' % category)))
440
535
 
441
536
 
 
537
class TestFileIdMapping(TestCase):
 
538
 
 
539
    def test_slash(self):
 
540
        from bzrlib.plugins.bzrtools.baz_import import map_file_id
 
541
        self.assertEqual('c%2fc', map_file_id('c/c'))
 
542
        self.assertEqual('c%25c', map_file_id('c%c'))
 
543
 
 
544
 
442
545
class TestImport(TestCaseInTempDir):
443
546
 
444
547
    def setUp(self):