~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 05:30:30 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115053030-1d6qd89pnj8hmb55
Pass kinds (not pairs) to MergeHookParams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Black box tests for the upgrade ui."""
18
18
 
42
42
        self.old_format = bzrdir.BzrDirFormat.get_default_format()
43
43
        self.old_ui_factory = ui.ui_factory
44
44
        self.addCleanup(self.restoreDefaults)
45
 
 
46
45
        ui.ui_factory = TestUIFactory()
 
46
 
 
47
    def restoreDefaults(self):
 
48
        ui.ui_factory = self.old_ui_factory
 
49
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
 
50
 
 
51
    def make_current_format_branch_and_checkout(self):
 
52
        current_tree = self.make_branch_and_tree('current_format_branch',
 
53
                                                 format='default')
 
54
        current_tree.branch.create_checkout(
 
55
            self.get_url('current_format_checkout'), lightweight=True)
 
56
 
 
57
    def make_format_5_branch(self):
47
58
        # setup a format 5 branch we can upgrade from.
48
59
        self.make_branch_and_tree('format_5_branch',
49
60
                                  format=bzrdir.BzrDirFormat5())
50
61
 
51
 
        current_tree = self.make_branch_and_tree('current_format_branch',
52
 
                                                 format='default')
 
62
    def make_metadir_weave_branch(self):
53
63
        self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
54
 
        current_tree.branch.create_checkout(
55
 
            self.get_url('current_format_checkout'), lightweight=True)
56
 
 
57
 
    def restoreDefaults(self):
58
 
        ui.ui_factory = self.old_ui_factory
59
 
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
60
64
 
61
65
    def test_readonly_url_error(self):
 
66
        self.make_format_5_branch()
62
67
        (out, err) = self.run_bzr(
63
68
            ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
64
69
        self.assertEqual(out, "")
65
70
        self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
66
71
 
67
72
    def test_upgrade_up_to_date(self):
 
73
        self.make_current_format_branch_and_checkout()
68
74
        # when up to date we should get a message to that effect
69
75
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
70
76
        self.assertEqual("", out)
71
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
72
 
                             "directory, format 1 is already at the most "
 
77
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
78
                             "directory format 1 is already at the most "
73
79
                             "recent format.\n", err)
74
80
 
75
81
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
 
82
        self.make_current_format_branch_and_checkout()
76
83
        # when upgrading a checkout, the branch location and a suggestion
77
 
        # to upgrade it should be emitted even if the checkout is up to 
 
84
        # to upgrade it should be emitted even if the checkout is up to
78
85
        # date
79
86
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
80
87
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
81
88
                         "upgraded separately.\n"
82
89
                         % get_transport(self.get_url('current_format_branch')).base,
83
90
                         out)
84
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
85
 
                             "directory, format 1 is already at the most "
 
91
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
92
                             "directory format 1 is already at the most "
86
93
                             "recent format.\n", err)
87
94
 
88
95
    def test_upgrade_checkout(self):
90
97
        pass
91
98
 
92
99
    def test_upgrade_repository_scans_branches(self):
93
 
        # we should get individual upgrade notes for each branch even the 
 
100
        # we should get individual upgrade notes for each branch even the
94
101
        # anonymous branch
95
102
        pass
96
103
 
100
107
 
101
108
    def test_upgrade_explicit_metaformat(self):
102
109
        # users can force an upgrade to metadir format.
 
110
        self.make_format_5_branch()
103
111
        url = get_transport(self.get_url('format_5_branch')).base
104
112
        # check --format takes effect
105
113
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
120
128
            bzrdir.BzrDirMetaFormat1))
121
129
 
122
130
    def test_upgrade_explicit_knit(self):
123
 
        # users can force an upgrade to knit format from a metadir weave 
 
131
        # users can force an upgrade to knit format from a metadir weave
124
132
        # branch
 
133
        self.make_metadir_weave_branch()
125
134
        url = get_transport(self.get_url('metadir_weave_branch')).base
126
135
        # check --format takes effect
127
136
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
175
184
        self.assertEqual('', err)
176
185
 
177
186
 
178
 
class UpgradeRecommendedTests(TestCaseInTempDir):
 
187
class UpgradeRecommendedTests(TestCaseWithTransport):
179
188
 
180
189
    def test_recommend_upgrade_wt4(self):
181
190
        # using a deprecated format gives a warning
191
200
        out, err = self.run_bzr('revno a')
192
201
        if err.find('upgrade') > -1:
193
202
            self.fail("message shouldn't suggest upgrade:\n%s" % err)
 
203
 
 
204
    def test_upgrade_shared_repo(self):
 
205
        repo = self.make_repository('repo', format='2a', shared=True)
 
206
        branch = self.make_branch_and_tree('repo/branch', format="pack-0.92")
 
207
        self.get_transport('repo/branch/.bzr/repository').delete_tree('.')
 
208
        out, err = self.run_bzr(['upgrade'], working_dir='repo/branch')