187
188
class TestReconfigureStacking(tests.TestCaseWithTransport):
189
190
def test_reconfigure_stacking(self):
190
branch_1 = self.make_branch('b1', format='2a')
191
branch_2 = self.make_branch('b2', format='2a')
192
out, err = self.run_bzr('reconfigure --stacked-on b2 b1')
191
"""Test a fairly realistic scenario for stacking:
193
* make a branch with some history
195
* make the second branch stacked on the first
196
* commit in the second
197
* then make the second unstacked, so it has to fill in history from
198
the original fallback lying underneath its original content
200
See discussion in <https://bugs.edge.launchpad.net/bzr/+bug/391411>
202
tree_1 = self.make_branch_and_tree('b1', format='2a')
203
self.build_tree(['b1/foo'])
205
tree_1.commit('add foo')
206
branch_1 = tree_1.branch
207
# now branch and commit again
208
bzrdir_2 = tree_1.bzrdir.sprout('b2')
209
tree_2 = bzrdir_2.open_workingtree()
210
branch_2 = tree_2.branch
211
# now reconfigure to be stacked
212
out, err = self.run_bzr('reconfigure --stacked-on b1 b2')
193
213
self.assertContainsRe(out,
194
'^.*/b1/ is now stacked on ../b2\n$')
214
'^.*/b2/ is now stacked on ../b1\n$')
195
215
self.assertEquals('', err)
196
216
# It should be given a relative URL to the destination, if possible,
197
217
# because that's most likely to work across different transports
198
self.assertEquals(branch_1.get_stacked_on_url(),
218
self.assertEquals(branch_2.get_stacked_on_url(),
220
# commit, and it should be stored into b2's repo
221
self.build_tree_contents([('foo', 'new foo')])
222
tree_2.commit('update foo')
200
223
# Now turn it off again
201
out, err = self.run_bzr('reconfigure --unstacked b1')
224
out, err = self.run_bzr('reconfigure --unstacked b2')
202
225
self.assertContainsRe(out,
203
'^.*/b1/ is now not stacked\n$')
226
'^.*/b2/ is now not stacked\n$')
204
227
self.assertEquals('', err)
205
228
self.assertRaises(errors.NotStacked,
206
branch_1.get_stacked_on_url)
229
branch_2.get_stacked_on_url)
208
231
# XXX: Needs a test for reconfiguring stacking and shape at the same time;
209
232
# no branch at location; stacked-on is not a branch; quiet mode;