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
27
30
from bzrlib.branch import Branch
31
import bzrlib.bzrdir as bzrdir
32
import bzrlib.repository as repository
28
33
from bzrlib.revision import is_ancestor
29
34
from bzrlib.tests import TestCase, TestCaseInTempDir
30
35
from bzrlib.transport import get_transport
31
36
from bzrlib.upgrade import upgrade
37
import bzrlib.workingtree as workingtree
34
40
class TestUpgrade(TestCaseInTempDir):
44
50
eq = self.assertEquals
45
51
self.build_tree_contents(_upgrade1_template)
53
control = bzrdir.BzrDir.open('.')
54
b = control.open_branch()
55
r = control.open_repository()
56
t = control.open_workingtree()
48
57
# tsk, peeking under the covers.
49
self.failUnless(isinstance(b._branch_format, branch.BzrBranchFormat6))
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))
50
62
rh = b.revision_history()
52
64
['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
53
65
'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
54
t = b.repository.revision_tree(rh[0])
66
rt = b.repository.revision_tree(rh[0])
55
67
foo_id = 'foo-20051004035605-91e788d1875603ae'
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')
68
eq(rt.get_file_text(foo_id), 'initial contents\n')
69
rt = b.repository.revision_tree(rh[1])
70
eq(rt.get_file_text(foo_id), 'new contents\n')
59
71
# check a backup was made:
60
72
transport = get_transport(b.base)
61
73
transport.stat('.bzr.backup')