~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Robert Collins
  • Date: 2005-10-20 01:09:24 UTC
  • mto: (147.1.39) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20051020010924-9524a948ff2bdbef
test escaping of file ids is working

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
 
393
425
 
394
426
class TestNamespacePrevious(TestCase):
395
427
 
439
471
                         map_namespace(pybaz.Version('%s--0.1' % category)))
440
472
 
441
473
 
 
474
class TestFileIdMapping(TestCase):
 
475
 
 
476
    def test_slash(self):
 
477
        from bzrlib.plugins.bzrtools.baz_import import map_file_id
 
478
        self.assertEqual('c%2fc', map_file_id('c/c'))
 
479
        self.assertEqual('c%25c', map_file_id('c%c'))
 
480
 
 
481
 
442
482
class TestImport(TestCaseInTempDir):
443
483
 
444
484
    def setUp(self):