1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Black-box tests for brz branch."""
27
from breezy.urlutils import local_path_to_url
30
class TestClone(tests.TestCaseWithTransport):
32
def example_dir(self, path='.', format=None):
33
tree = self.make_branch_and_tree(path, format=format)
34
self.build_tree_contents([(path + '/hello', b'foo')])
36
tree.commit(message='setup')
37
self.build_tree_contents([(path + '/goodbye', b'baz')])
39
tree.commit(message='setup')
43
"""Branch from one branch to another."""
45
self.run_bzr('clone a b')
46
b = branch.Branch.open('b')
47
self.run_bzr('clone a c -r 1')
48
# previously was erroneously created by branching
49
self.assertFalse(b._transport.has('branch-name'))
50
b.controldir.open_workingtree().commit(message='foo', allow_pointless=True)
52
def test_clone_no_to_location(self):
53
"""The to_location is derived from the source branch name."""
55
a = self.example_dir('something/a').branch
56
self.run_bzr('clone something/a')
57
b = branch.Branch.open('a')
58
self.assertEqual(b.last_revision_info(), a.last_revision_info())
60
def test_from_colocated(self):
61
"""Branch from a colocated branch into a regular branch."""
63
tree = self.example_dir('b/a')
64
tree.controldir.create_branch(name='somecolo')
65
out, err = self.run_bzr('clone %s' % local_path_to_url('b/a'))
66
self.assertEqual('', out)
67
self.assertEqual('Created new control directory.\n', err)
68
self.assertPathExists('a')
69
target = controldir.ControlDir.open('a')
70
self.assertEqual(['', 'somecolo'], target.branch_names())