~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_upgrade.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:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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'.')
131
131
        self.build_tree_contents(_upgrade_dir_template)
132
132
        upgrade('.', bzrdir.BzrDirMetaFormat1())
133
133
        tree = workingtree.WorkingTree.open('.')
134
 
        self.assertEqual(tree.last_revision(),
135
 
                         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'])
136
161
 
137
162
 
138
163
_upgrade1_template = \