~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2009-07-08 08:48:45 UTC
  • mto: This revision was merged to the branch mainline in revision 4566.
  • Revision ID: mbp@sourcefrog.net-20090708084845-yrto0e8wnre1a90u
More realistic and now failing test_reconfigure_stacking

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    tests,
21
21
    workingtree,
22
22
    )
 
23
from bzrlib.branchbuilder import BranchBuilder
23
24
 
24
25
 
25
26
class TestReconfigure(tests.TestCaseWithTransport):
187
188
class TestReconfigureStacking(tests.TestCaseWithTransport):
188
189
 
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:
 
192
 
 
193
         * make a branch with some history
 
194
         * branch it
 
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
 
199
 
 
200
        See discussion in <https://bugs.edge.launchpad.net/bzr/+bug/391411>
 
201
        """
 
202
        tree_1 = self.make_branch_and_tree('b1', format='2a')
 
203
        self.build_tree(['b1/foo'])
 
204
        tree_1.add(['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(),
199
 
            '../b2')
 
218
        self.assertEquals(branch_2.get_stacked_on_url(),
 
219
            '../b1')
 
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)
207
230
 
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;