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