~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_upgrade.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-23 08:51:52 UTC
  • mfrom: (5131.2.6 support_OO_flag)
  • mto: This revision was merged to the branch mainline in revision 5179.
  • Revision ID: v.ladeuil+lp@free.fr-20100423085152-uoewc1vnkwqhw0pj
Manually assign docstrings to command objects, so that they work with python -OO

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib import (
22
22
    bzrdir,
23
 
    controldir,
24
 
    transport,
 
23
    repository,
25
24
    )
26
25
from bzrlib.tests import (
27
26
    features,
 
27
    TestCaseInTempDir,
28
28
    TestCaseWithTransport,
29
29
    )
30
30
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
 
31
from bzrlib.transport import get_transport
31
32
from bzrlib.repofmt.knitrepo import (
32
33
    RepositoryFormatKnit1,
33
34
    )
37
38
 
38
39
    def setUp(self):
39
40
        super(TestWithUpgradableBranches, self).setUp()
40
 
        self.addCleanup(controldir.ControlDirFormat._set_default_format,
41
 
                        controldir.ControlDirFormat.get_default_format())
 
41
        self.addCleanup(bzrdir.BzrDirFormat._set_default_format,
 
42
                        bzrdir.BzrDirFormat.get_default_format())
42
43
 
43
44
    def make_current_format_branch_and_checkout(self):
44
45
        current_tree = self.make_branch_and_tree('current_format_branch',
78
79
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
79
80
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
80
81
                         "upgraded separately.\n"
81
 
                         % transport.get_transport(
82
 
                self.get_url('current_format_branch')).base,
 
82
                         % get_transport(self.get_url('current_format_branch')).base,
83
83
                         out)
84
84
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
85
85
                             "directory format 1 is already at the most "
101
101
    def test_upgrade_explicit_metaformat(self):
102
102
        # users can force an upgrade to metadir format.
103
103
        self.make_format_5_branch()
104
 
        url = transport.get_transport(self.get_url('format_5_branch')).base
 
104
        url = get_transport(self.get_url('format_5_branch')).base
105
105
        # check --format takes effect
106
 
        controldir.ControlDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
106
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
107
107
        backup_dir = 'backup.bzr.~1~'
108
108
        (out, err) = self.run_bzr(
109
109
            ['upgrade', '--format=metaweave', url])
125
125
        # users can force an upgrade to knit format from a metadir weave
126
126
        # branch
127
127
        self.make_metadir_weave_branch()
128
 
        url = transport.get_transport(self.get_url('metadir_weave_branch')).base
 
128
        url = get_transport(self.get_url('metadir_weave_branch')).base
129
129
        # check --format takes effect
130
 
        controldir.ControlDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
130
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
131
131
        backup_dir = 'backup.bzr.~1~'
132
132
        (out, err) = self.run_bzr(
133
133
            ['upgrade', '--format=knit', url])
163
163
 
164
164
    def test_upgrade_with_existing_backup_dir(self):
165
165
        self.make_format_5_branch()
166
 
        t = transport.get_transport(self.get_url('format_5_branch'))
167
 
        url = t.base
168
 
        controldir.ControlDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
166
        transport = get_transport(self.get_url('format_5_branch'))
 
167
        url = transport.base
 
168
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
169
169
        backup_dir1 = 'backup.bzr.~1~'
170
170
        backup_dir2 = 'backup.bzr.~2~'
171
171
        # explicitly create backup_dir1. bzr should create the .~2~ directory
172
172
        # as backup
173
 
        t.mkdir(backup_dir1)
 
173
        transport.mkdir(backup_dir1)
174
174
        (out, err) = self.run_bzr(
175
175
            ['upgrade', '--format=metaweave', url])
176
176
        self.assertEqualDiff("""starting upgrade of %s
186
186
        self.assertTrue(isinstance(
187
187
            bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
188
188
            bzrdir.BzrDirMetaFormat1))
189
 
        self.assertTrue(t.has(backup_dir2))
 
189
        self.assertTrue(transport.has(backup_dir2))
190
190
 
191
191
class SFTPTests(TestCaseWithSFTPServer):
192
192
    """Tests for upgrade over sftp."""
193
193
 
194
194
    def test_upgrade_url(self):
195
195
        self.run_bzr('init --format=weave')
196
 
        t = transport.get_transport(self.get_url())
 
196
        t = get_transport(self.get_url())
197
197
        url = t.base
198
198
        out, err = self.run_bzr(['upgrade', '--format=knit', url])
199
199
        backup_dir = 'backup.bzr.~1~'