~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from bzrlib.transport import get_transport
39
39
from bzrlib.transport.http import HttpServer
40
40
from bzrlib.transport.memory import MemoryServer
 
41
from bzrlib import upgrade, workingtree
41
42
 
42
43
 
43
44
class TestDefaultFormat(TestCase):
44
45
 
45
46
    def test_get_set_default_format(self):
 
47
        private_default = repository._default_format.__class__
46
48
        old_format = repository.RepositoryFormat.get_default_format()
47
 
        self.assertTrue(isinstance(old_format, repository.RepositoryFormatKnit1))
 
49
        self.assertTrue(isinstance(old_format, private_default))
48
50
        repository.RepositoryFormat.set_default_format(SampleRepositoryFormat())
49
51
        # creating a repository should now create an instrumented dir.
50
52
        try:
72
74
    def initialize(self, a_bzrdir, shared=False):
73
75
        """Initialize a repository in a BzrDir"""
74
76
        t = a_bzrdir.get_repository_transport(self)
75
 
        t.put('format', StringIO(self.get_format_string()))
 
77
        t.put_bytes('format', self.get_format_string())
76
78
        return 'A bzr repository dir'
77
79
 
78
80
    def is_supported(self):
435
437
    def test_unescape_xml(self):
436
438
        """We get some kind of error when malformed entities are passed"""
437
439
        self.assertRaises(KeyError, repository._unescape_xml, 'foo&bar;') 
 
440
 
 
441
 
 
442
class TestRepositoryFormatKnit2(TestCaseWithTransport):
 
443
 
 
444
    def test_convert(self):
 
445
        """Ensure the upgrade adds weaves for roots"""
 
446
        format = bzrdir.BzrDirMetaFormat1()
 
447
        format.repository_format = repository.RepositoryFormatKnit1()
 
448
        tree = self.make_branch_and_tree('.', format)
 
449
        tree.commit("Dull commit", rev_id="dull")
 
450
        revision_tree = tree.branch.repository.revision_tree('dull')
 
451
        self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
 
452
            revision_tree.inventory.root.file_id)
 
453
        format = bzrdir.BzrDirMetaFormat1()
 
454
        format.repository_format = repository.RepositoryFormatKnit2()
 
455
        upgrade.Convert('.', format)
 
456
        tree = workingtree.WorkingTree.open('.')
 
457
        revision_tree = tree.branch.repository.revision_tree('dull')
 
458
        revision_tree.get_file_lines(revision_tree.inventory.root.file_id)
 
459
        tree.commit("Another dull commit", rev_id='dull2')
 
460
        revision_tree = tree.branch.repository.revision_tree('dull2')
 
461
        self.assertEqual('dull', revision_tree.inventory.root.revision)