1
# Copyright (C) 2007, 2009 Canonical Ltd
1
# Copyright (C) 2007-2012 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
from bzrlib import (
23
from bzrlib.branchbuilder import BranchBuilder
24
23
from bzrlib.tests.script import TestCaseWithTransportAndScript
87
86
def test_use_shared_to_standalone(self):
88
87
repo = self.make_repository('repo', shared=True)
89
branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
88
branch = controldir.ControlDir.create_branch_convenience('repo/tree')
90
89
self.assertNotEqual(branch.bzrdir.root_transport.base,
91
90
branch.repository.bzrdir.root_transport.base)
92
91
self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
127
126
def test_make_without_trees_leaves_tree_alone(self):
128
127
repo = self.make_repository('repo', shared=True)
129
branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
128
branch = controldir.ControlDir.create_branch_convenience('repo/branch')
130
129
tree = workingtree.WorkingTree.open('repo/branch')
131
130
self.build_tree(['repo/branch/foo'])
138
137
def test_shared_format_to_standalone(self, format=None):
139
138
repo = self.make_repository('repo', shared=True, format=format)
140
branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
139
branch = controldir.ControlDir.create_branch_convenience('repo/tree')
141
140
self.assertNotEqual(branch.bzrdir.root_transport.base,
142
141
branch.repository.bzrdir.root_transport.base)
143
142
tree = workingtree.WorkingTree.open('repo/tree')
242
241
branch_2 = tree_2.branch
243
242
# now reconfigure to be stacked
244
243
out, err = self.run_bzr('reconfigure --stacked-on b1 b2')
245
self.assertContainsRe(out,
246
'^.*/b2/ is now stacked on ../b1\n$')
244
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
247
245
self.assertEquals('', err)
248
246
# can also give the absolute URL of the branch, and it gets stored
249
247
# as a relative path if possible
250
248
out, err = self.run_bzr('reconfigure --stacked-on %s b2'
251
% (self.get_url('b1'),))
252
self.assertContainsRe(out,
253
'^.*/b2/ is now stacked on ../b1\n$')
249
% (self.get_url('b1'),))
250
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
254
251
self.assertEquals('', err)
252
# Refresh the branch as 'reconfigure' modified it
253
branch_2 = branch_2.bzrdir.open_branch()
255
254
# It should be given a relative URL to the destination, if possible,
256
255
# because that's most likely to work across different transports
257
self.assertEquals(branch_2.get_stacked_on_url(),
256
self.assertEquals('../b1', branch_2.get_stacked_on_url())
259
257
# commit, and it should be stored into b2's repo
260
258
self.build_tree_contents([('foo', 'new foo')])
261
259
tree_2.commit('update foo')
264
262
self.assertContainsRe(out,
265
263
'^.*/b2/ is now not stacked\n$')
266
264
self.assertEquals('', err)
267
self.assertRaises(errors.NotStacked,
268
branch_2.get_stacked_on_url)
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)
270
269
# XXX: Needs a test for reconfiguring stacking and shape at the same time;
271
270
# no branch at location; stacked-on is not a branch; quiet mode.