/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_clone.py

  • Committer: Jelmer Vernooij
  • Date: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
 
 
18
"""Black-box tests for brz branch."""
 
19
 
 
20
import os
 
21
 
 
22
from breezy import (
 
23
    branch,
 
24
    controldir,
 
25
    tests,
 
26
    )
 
27
from breezy.urlutils import local_path_to_url
 
28
 
 
29
 
 
30
class TestClone(tests.TestCaseWithTransport):
 
31
 
 
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')])
 
35
        tree.add('hello')
 
36
        tree.commit(message='setup')
 
37
        self.build_tree_contents([(path + '/goodbye', b'baz')])
 
38
        tree.add('goodbye')
 
39
        tree.commit(message='setup')
 
40
        return tree
 
41
 
 
42
    def test_clone(self):
 
43
        """Branch from one branch to another."""
 
44
        self.example_dir('a')
 
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)
 
51
 
 
52
    def test_clone_no_to_location(self):
 
53
        """The to_location is derived from the source branch name."""
 
54
        os.mkdir("something")
 
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())
 
59
 
 
60
    def test_from_colocated(self):
 
61
        """Branch from a colocated branch into a regular branch."""
 
62
        os.mkdir('b')
 
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())