5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2008, 2009, 2011 Canonical Ltd
|
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
16 |
|
17 |
||
18 |
"""Tests for upgrades of various stacking situations."""
|
|
19 |
||
20 |
from bzrlib import ( |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
21 |
controldir, |
4332.3.35
by Robert Collins
Fix failing tests. |
22 |
check, |
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
23 |
errors, |
24 |
tests, |
|
25 |
)
|
|
26 |
from bzrlib.upgrade import upgrade |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
27 |
from bzrlib.tests.scenarios import load_tests_apply_scenarios |
28 |
||
29 |
||
30 |
def upgrade_scenarios(): |
|
31 |
scenario_pairs = [ # old format, new format, model_change |
|
32 |
# ('knit', 'rich-root', True),
|
|
33 |
('knit', '1.6', False), |
|
34 |
# ('pack-0.92', '1.6', False),
|
|
35 |
('1.6', '1.6.1-rich-root', True), |
|
36 |
]
|
|
37 |
scenarios = [] |
|
38 |
for (old_name, new_name, model_change) in scenario_pairs: |
|
39 |
name = old_name + ', ' + new_name |
|
40 |
scenarios.append((name, |
|
41 |
dict(scenario_old_format=old_name, |
|
42 |
scenario_new_format=new_name, |
|
43 |
scenario_model_change=model_change))) |
|
44 |
return scenarios |
|
45 |
||
46 |
||
47 |
load_tests = load_tests_apply_scenarios |
|
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
48 |
|
49 |
||
50 |
class TestStackUpgrade(tests.TestCaseWithTransport): |
|
51 |
# TODO: This should possibly be repeated for all stacking repositories,
|
|
52 |
# pairwise by rich/non-rich format; should possibly also try other kinds
|
|
53 |
# of upgrades like knit->pack. -- mbp 20080804
|
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
54 |
|
55 |
scenarios = upgrade_scenarios() |
|
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
56 |
|
57 |
def test_stack_upgrade(self): |
|
58 |
"""Correct checks when stacked-on repository is upgraded.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
59 |
|
60 |
We initially stack on a repo with the same rich root support,
|
|
61 |
we then upgrade it and should fail, we then upgrade the overlaid
|
|
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
62 |
repository.
|
63 |
"""
|
|
64 |
base = self.make_branch_and_tree('base', |
|
65 |
format=self.scenario_old_format) |
|
66 |
self.build_tree(['base/foo']) |
|
67 |
base.commit('base commit') |
|
68 |
# make another one stacked
|
|
69 |
stacked = base.bzrdir.sprout('stacked', stacked=True) |
|
70 |
# this must really be stacked (or get_stacked_on_url raises an error)
|
|
71 |
self.assertTrue(stacked.open_branch().get_stacked_on_url()) |
|
72 |
# now we'll upgrade the underlying branch, then upgrade the stacked
|
|
73 |
# branch, and this should still work.
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
74 |
new_format = controldir.format_registry.make_bzrdir( |
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
75 |
self.scenario_new_format) |
76 |
upgrade('base', new_format) |
|
77 |
# in some cases you'll get an error if the underlying model has
|
|
78 |
# changed; if just the data format has changed this should still work
|
|
79 |
if self.scenario_model_change: |
|
80 |
self.assertRaises(errors.IncompatibleRepositories, |
|
81 |
stacked.open_branch) |
|
82 |
else: |
|
4332.3.35
by Robert Collins
Fix failing tests. |
83 |
check.check_dwim('stacked', False, True, True) |
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
84 |
stacked = controldir.ControlDir.open('stacked') |
3602.2.2
by Martin Pool
Make tests for stacked upgrade scenario-based |
85 |
# but we can upgrade the stacked repository
|
86 |
upgrade('stacked', new_format) |
|
4332.3.35
by Robert Collins
Fix failing tests. |
87 |
# and now it opens ok
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
88 |
stacked = controldir.ControlDir.open('stacked') |
4332.3.35
by Robert Collins
Fix failing tests. |
89 |
# And passes check.
|
90 |
check.check_dwim('stacked', False, True, True) |