19
19
This file contains canned versions of some old trees, which are instantiated
20
20
and then upgraded to the new format."""
22
# TODO queue for upgrade:
23
# test the error message when upgrading an unknown BzrDir format.
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
40
34
class TestUpgrade(TestCaseInTempDir):
50
44
eq = self.assertEquals
51
45
self.build_tree_contents(_upgrade1_template)
53
control = bzrdir.BzrDir.open('.')
54
b = control.open_branch()
55
48
# tsk, peeking under the covers.
59
bzrdir.BzrDirFormat.get_default_format().__class__))
49
self.failUnless(isinstance(b._branch_format, branch.BzrBranchFormat6))
60
50
rh = b.revision_history()
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')
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
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
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'
126
repo.text_store.get_weave(
127
'dir-20051005095101-da1441ea3fa6917a',
128
repo.get_transaction()))
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')
138
111
_upgrade1_template = \