86
80
def test_use_shared_to_standalone(self):
87
81
repo = self.make_repository('repo', shared=True)
88
branch = controldir.ControlDir.create_branch_convenience('repo/tree')
89
self.assertNotEqual(branch.bzrdir.root_transport.base,
90
branch.repository.bzrdir.root_transport.base)
91
self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
92
tree = workingtree.WorkingTree.open('repo/tree')
93
self.assertEqual(tree.bzrdir.root_transport.base,
94
tree.branch.repository.bzrdir.root_transport.base)
96
def test_make_with_trees(self):
97
repo = self.make_repository('repo', shared=True)
98
repo.set_make_working_trees(False)
99
self.run_bzr('reconfigure --with-trees', working_dir='repo')
100
self.assertIs(True, repo.make_working_trees())
102
def test_make_with_trees_already_trees(self):
103
repo = self.make_repository('repo', shared=True)
104
repo.set_make_working_trees(True)
105
self.run_bzr_error([" already creates working trees"],
106
'reconfigure --with-trees repo')
108
def test_make_without_trees(self):
109
repo = self.make_repository('repo', shared=True)
110
repo.set_make_working_trees(True)
111
self.run_bzr('reconfigure --with-no-trees', working_dir='repo')
112
self.assertIs(False, repo.make_working_trees())
114
def test_make_without_trees_already_no_trees(self):
115
repo = self.make_repository('repo', shared=True)
116
repo.set_make_working_trees(False)
117
self.run_bzr_error([" already doesn't create working trees"],
118
'reconfigure --with-no-trees repo')
120
def test_make_with_trees_nonshared_repo(self):
121
branch = self.make_branch('branch')
123
["Requested reconfiguration of '.*' is not supported"],
124
'reconfigure --with-trees branch')
126
def test_make_without_trees_leaves_tree_alone(self):
127
repo = self.make_repository('repo', shared=True)
128
branch = controldir.ControlDir.create_branch_convenience('repo/branch')
129
tree = workingtree.WorkingTree.open('repo/branch')
130
self.build_tree(['repo/branch/foo'])
132
self.run_bzr('reconfigure --with-no-trees --force',
133
working_dir='repo/branch')
134
self.assertPathExists('repo/branch/foo')
135
tree = workingtree.WorkingTree.open('repo/branch')
137
def test_shared_format_to_standalone(self, format=None):
138
repo = self.make_repository('repo', shared=True, format=format)
139
branch = controldir.ControlDir.create_branch_convenience('repo/tree')
140
self.assertNotEqual(branch.bzrdir.root_transport.base,
141
branch.repository.bzrdir.root_transport.base)
142
tree = workingtree.WorkingTree.open('repo/tree')
143
self.build_tree_contents([('repo/tree/file', 'foo\n')]);
145
tree.commit('added file')
146
self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
147
tree = workingtree.WorkingTree.open('repo/tree')
148
self.build_tree_contents([('repo/tree/file', 'bar\n')]);
149
self.check_file_contents('repo/tree/file', 'bar\n')
150
self.run_bzr('revert', working_dir='repo/tree')
151
self.check_file_contents('repo/tree/file', 'foo\n')
152
self.assertEqual(tree.bzrdir.root_transport.base,
153
tree.branch.repository.bzrdir.root_transport.base)
155
def test_shared_knit_to_standalone(self):
156
self.test_shared_format_to_standalone('knit')
158
def test_shared_pack092_to_standalone(self):
159
self.test_shared_format_to_standalone('pack-0.92')
161
def test_shared_rich_root_pack_to_standalone(self):
162
self.test_shared_format_to_standalone('rich-root-pack')
164
def test_lightweight_format_checkout_to_tree(self, format=None):
165
branch = self.make_branch('branch', format=format)
166
checkout = branch.create_checkout('checkout', lightweight=True)
167
tree = workingtree.WorkingTree.open('checkout')
168
self.build_tree_contents([('checkout/file', 'foo\n')]);
170
tree.commit('added file')
171
self.run_bzr('reconfigure --tree', working_dir='checkout')
172
tree = workingtree.WorkingTree.open('checkout')
173
self.build_tree_contents([('checkout/file', 'bar\n')]);
174
self.check_file_contents('checkout/file', 'bar\n')
175
self.run_bzr('revert', working_dir='checkout')
176
self.check_file_contents('checkout/file', 'foo\n')
178
def test_lightweight_knit_checkout_to_tree(self):
179
self.test_lightweight_format_checkout_to_tree('knit')
181
def test_lightweight_pack092_checkout_to_tree(self):
182
self.test_lightweight_format_checkout_to_tree('pack-0.92')
184
def test_lightweight_rich_root_pack_checkout_to_tree(self):
185
self.test_lightweight_format_checkout_to_tree('rich-root-pack')
187
def test_branch_and_use_shared(self):
190
$ echo foo > branch/foo
191
$ bzr add -q branch/foo
192
$ bzr commit -q -m msg branch
194
$ bzr reconfigure --branch --use-shared branch
196
Repository branch (format: ...)
199
repository branch: branch
202
def test_use_shared_and_branch(self):
205
$ echo foo > branch/foo
206
$ bzr add -q branch/foo
207
$ bzr commit -q -m msg branch
209
$ bzr reconfigure --use-shared --branch branch
211
Repository branch (format: ...)
214
repository branch: branch
218
class TestReconfigureStacking(tests.TestCaseWithTransport):
220
def test_reconfigure_stacking(self):
221
"""Test a fairly realistic scenario for stacking:
223
* make a branch with some history
225
* make the second branch stacked on the first
226
* commit in the second
227
* then make the second unstacked, so it has to fill in history from
228
the original fallback lying underneath its original content
230
See discussion in <https://bugs.launchpad.net/bzr/+bug/391411>
232
# there are also per_branch tests that exercise remote operation etc
233
tree_1 = self.make_branch_and_tree('b1', format='2a')
234
self.build_tree(['b1/foo'])
236
tree_1.commit('add foo')
237
branch_1 = tree_1.branch
238
# now branch and commit again
239
bzrdir_2 = tree_1.bzrdir.sprout('b2')
240
tree_2 = bzrdir_2.open_workingtree()
241
branch_2 = tree_2.branch
242
# now reconfigure to be stacked
243
out, err = self.run_bzr('reconfigure --stacked-on b1 b2')
244
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
245
self.assertEqual('', err)
246
# can also give the absolute URL of the branch, and it gets stored
247
# as a relative path if possible
248
out, err = self.run_bzr('reconfigure --stacked-on %s b2'
249
% (self.get_url('b1'),))
250
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
251
self.assertEqual('', err)
252
# Refresh the branch as 'reconfigure' modified it
253
branch_2 = branch_2.bzrdir.open_branch()
254
# It should be given a relative URL to the destination, if possible,
255
# because that's most likely to work across different transports
256
self.assertEqual('../b1', branch_2.get_stacked_on_url())
257
# commit, and it should be stored into b2's repo
258
self.build_tree_contents([('foo', 'new foo')])
259
tree_2.commit('update foo')
260
# Now turn it off again
261
out, err = self.run_bzr('reconfigure --unstacked b2')
262
self.assertContainsRe(out,
263
'^.*/b2/ is now not stacked\n$')
264
self.assertEqual('', err)
265
# Refresh the branch as 'reconfigure' modified it
266
branch_2 = branch_2.bzrdir.open_branch()
267
self.assertRaises(errors.NotStacked, branch_2.get_stacked_on_url)
269
# XXX: Needs a test for reconfiguring stacking and shape at the same time;
270
# no branch at location; stacked-on is not a branch; quiet mode.
82
branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
83
self.assertNotEqual(branch.bzrdir.root_transport.base,
84
branch.repository.bzrdir.root_transport.base)
85
self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
86
tree = workingtree.WorkingTree.open('repo/tree')
87
self.assertEqual(tree.bzrdir.root_transport.base,
88
tree.branch.repository.bzrdir.root_transport.base)