~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_upgrade.py

first cut at merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
This file contains canned versions of some old trees, which are instantiated 
20
20
and then upgraded to the new format."""
21
21
 
22
 
# TODO queue for upgrade:
23
 
# test the error message when upgrading an unknown BzrDir format.
24
 
 
25
22
import base64
26
23
import os
27
24
import sys
28
25
 
29
 
import bzrlib.branch
 
26
import bzrlib.branch as branch
30
27
from bzrlib.branch import Branch
31
 
import bzrlib.bzrdir as bzrdir
32
 
import bzrlib.repository as repository
33
28
from bzrlib.revision import is_ancestor
34
29
from bzrlib.tests import TestCase, TestCaseInTempDir
35
30
from bzrlib.transport import get_transport
36
31
from bzrlib.upgrade import upgrade
37
 
import bzrlib.workingtree as workingtree
38
32
 
39
33
 
40
34
class TestUpgrade(TestCaseInTempDir):
50
44
        eq = self.assertEquals
51
45
        self.build_tree_contents(_upgrade1_template)
52
46
        upgrade(u'.')
53
 
        control = bzrdir.BzrDir.open('.')
54
 
        b = control.open_branch()
 
47
        b = Branch.open(u'.')
55
48
        # tsk, peeking under the covers.
56
 
        self.failUnless(
57
 
            isinstance(
58
 
                control._format,
59
 
                bzrdir.BzrDirFormat.get_default_format().__class__))
 
49
        self.failUnless(isinstance(b._branch_format, branch.BzrBranchFormat6))
60
50
        rh = b.revision_history()
61
51
        eq(rh,
62
52
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
63
53
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
64
 
        rt = b.repository.revision_tree(rh[0])
 
54
        t = b.repository.revision_tree(rh[0])
65
55
        foo_id = 'foo-20051004035605-91e788d1875603ae'
66
 
        eq(rt.get_file_text(foo_id), 'initial contents\n')
67
 
        rt = b.repository.revision_tree(rh[1])
68
 
        eq(rt.get_file_text(foo_id), 'new contents\n')
 
56
        eq(t.get_file_text(foo_id), 'initial contents\n')
 
57
        t = b.repository.revision_tree(rh[1])
 
58
        eq(t.get_file_text(foo_id), 'new contents\n')
69
59
        # check a backup was made:
70
60
        transport = get_transport(b.base)
71
61
        transport.stat('.bzr.backup')
110
100
 
111
101
    def test_upgrade_makes_dir_weaves(self):
112
102
        self.build_tree_contents(_upgrade_dir_template)
113
 
        old_repodir = bzrlib.bzrdir.BzrDir.open_unsupported('.')
114
 
        old_repo_format = old_repodir.open_repository()._format
115
103
        upgrade('.')
116
104
        # this is the path to the literal file. As format changes 
117
105
        # occur it needs to be updated. FIXME: ask the store for the
118
106
        # path.
119
 
        repo = bzrlib.repository.Repository.open('.')
120
 
        # it should have changed the format
121
 
        self.assertNotEqual(old_repo_format.__class__, repo._format.__class__)
122
 
        # and we should be able to read the names for the file id 
123
 
        # 'dir-20051005095101-da1441ea3fa6917a'
124
 
        self.assertNotEqual(
125
 
            [],
126
 
            repo.text_store.get_weave(
127
 
                'dir-20051005095101-da1441ea3fa6917a',
128
 
                repo.get_transaction()))
129
 
 
130
 
    def test_upgrade_to_meta_sets_workingtree_last_revision(self):
131
 
        self.build_tree_contents(_upgrade_dir_template)
132
 
        upgrade('.', bzrdir.BzrDirMetaFormat1())
133
 
        tree = workingtree.WorkingTree.open('.')
134
 
        self.assertEqual(tree.last_revision(),
135
 
                         tree.branch.revision_history()[-1])
 
107
        self.failUnlessExists(
 
108
            '.bzr/weaves/de/dir-20051005095101-da1441ea3fa6917a.weave')
136
109
 
137
110
 
138
111
_upgrade1_template = \