/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_upgrade.py

  • Committer: Martin Pool
  • Date: 2006-10-06 02:04:17 UTC
  • mfrom: (1908.10.1 bench_usecases.merge2)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: mbp@sourcefrog.net-20061006020417-4949ca86f4417a4d
merge additional fix from cfbolz

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        self.failUnlessExists('.bzr/README')
47
47
 
48
48
    def test_upgrade_simple(self):
49
 
        """Upgrade simple v0.0.4 format to v6"""
 
49
        """Upgrade simple v0.0.4 format to latest format"""
50
50
        eq = self.assertEquals
51
51
        self.build_tree_contents(_upgrade1_template)
52
52
        upgrade(u'.')
53
53
        control = bzrdir.BzrDir.open('.')
54
54
        b = control.open_branch()
55
 
        r = control.open_repository()
56
 
        t = control.open_workingtree()
57
55
        # tsk, peeking under the covers.
58
 
        self.failUnless(isinstance(control._format, bzrdir.BzrDirFormat6))
59
 
        self.failUnless(isinstance(b._format, bzrlib.branch.BzrBranchFormat4))
60
 
        self.failUnless(isinstance(r._format, repository.RepositoryFormat6))
61
 
        self.failUnless(isinstance(t._format, workingtree.WorkingTreeFormat2))
 
56
        self.failUnless(
 
57
            isinstance(
 
58
                control._format,
 
59
                bzrdir.BzrDirFormat.get_default_format().__class__))
62
60
        rh = b.revision_history()
63
61
        eq(rh,
64
62
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
112
110
 
113
111
    def test_upgrade_makes_dir_weaves(self):
114
112
        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
115
        upgrade('.')
116
116
        # this is the path to the literal file. As format changes 
117
117
        # occur it needs to be updated. FIXME: ask the store for the
118
118
        # path.
119
 
        self.failUnlessExists(
120
 
            '.bzr/weaves/de/dir-20051005095101-da1441ea3fa6917a.weave')
 
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()))
121
129
 
122
130
    def test_upgrade_to_meta_sets_workingtree_last_revision(self):
123
131
        self.build_tree_contents(_upgrade_dir_template)
124
132
        upgrade('.', bzrdir.BzrDirMetaFormat1())
125
133
        tree = workingtree.WorkingTree.open('.')
126
 
        self.assertEqual(tree.last_revision(),
127
 
                         tree.branch.revision_history()[-1])
 
134
        self.assertEqual([tree.branch.revision_history()[-1]],
 
135
            tree.get_parent_ids())
 
136
 
 
137
    def test_upgrade_v6_to_meta_no_workingtree(self):
 
138
        # Some format6 branches do not have checkout files. Upgrading
 
139
        # such a branch to metadir must not setup a working tree.
 
140
        self.build_tree_contents(_upgrade1_template)
 
141
        upgrade('.', bzrdir.BzrDirFormat6())
 
142
        transport = get_transport('.')
 
143
        transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
 
144
        assert not transport.has('.bzr/stat-cache')
 
145
        # XXX: upgrade fails if a .bzr.backup is already present
 
146
        # -- David Allouche 2006-08-11
 
147
        transport.delete_tree('.bzr.backup')
 
148
        # At this point, we have a format6 branch without checkout files.
 
149
        upgrade('.', bzrdir.BzrDirMetaFormat1())
 
150
        # The upgrade should not have set up a working tree.
 
151
        control = bzrdir.BzrDir.open('.')
 
152
        self.assertFalse(control.has_workingtree())
 
153
        # We have covered the scope of this test, we may as well check that
 
154
        # upgrade has not eaten our data, even if it's a bit redundant with
 
155
        # other tests.
 
156
        self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1))
 
157
        branch = control.open_branch()
 
158
        self.assertEquals(branch.revision_history(),
 
159
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
 
160
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
128
161
 
129
162
 
130
163
_upgrade1_template = \