~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib import (
22
22
    bzrdir,
23
 
    repository,
 
23
    controldir,
 
24
    transport,
24
25
    )
25
26
from bzrlib.tests import (
26
27
    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
32
31
from bzrlib.repofmt.knitrepo import (
33
32
    RepositoryFormatKnit1,
34
33
    )
38
37
 
39
38
    def setUp(self):
40
39
        super(TestWithUpgradableBranches, self).setUp()
41
 
        self.addCleanup(bzrdir.BzrDirFormat._set_default_format,
42
 
                        bzrdir.BzrDirFormat.get_default_format())
 
40
        self.addCleanup(controldir.ControlDirFormat._set_default_format,
 
41
                        controldir.ControlDirFormat.get_default_format())
43
42
 
44
43
    def make_current_format_branch_and_checkout(self):
45
44
        current_tree = self.make_branch_and_tree('current_format_branch',
79
78
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
80
79
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
81
80
                         "upgraded separately.\n"
82
 
                         % get_transport(self.get_url('current_format_branch')).base,
 
81
                         % transport.get_transport(
 
82
                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 = get_transport(self.get_url('format_5_branch')).base
 
104
        url = transport.get_transport(self.get_url('format_5_branch')).base
105
105
        # check --format takes effect
106
 
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
106
        controldir.ControlDirFormat._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 = get_transport(self.get_url('metadir_weave_branch')).base
 
128
        url = transport.get_transport(self.get_url('metadir_weave_branch')).base
129
129
        # check --format takes effect
130
 
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
130
        controldir.ControlDirFormat._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
 
        transport = get_transport(self.get_url('format_5_branch'))
167
 
        url = transport.base
168
 
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
 
166
        t = transport.get_transport(self.get_url('format_5_branch'))
 
167
        url = t.base
 
168
        controldir.ControlDirFormat._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
 
        transport.mkdir(backup_dir1)
 
173
        t.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(transport.has(backup_dir2))
 
189
        self.assertTrue(t.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 = get_transport(self.get_url())
 
196
        t = transport.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~'