/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 bzrlib/tests/blackbox/test_checkout.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
2
2
#
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
18
18
 
19
19
import os
20
20
 
21
 
from breezy import (
 
21
from bzrlib import (
22
22
    branch as _mod_branch,
 
23
    bzrdir,
23
24
    controldir,
24
25
    errors,
25
26
    workingtree,
26
27
    )
27
 
from breezy.bzr import (
28
 
    bzrdir,
29
 
    )
30
 
from breezy.tests import (
 
28
from bzrlib.tests import (
31
29
    TestCaseWithTransport,
32
30
    )
33
 
from breezy.tests.matchers import ContainsNoVfsCalls
34
 
from breezy.tests.features import (
 
31
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
32
from bzrlib.tests.features import (
35
33
    HardlinkFeature,
36
34
    )
37
35
 
41
39
    def setUp(self):
42
40
        super(TestCheckout, self).setUp()
43
41
        tree = controldir.ControlDir.create_standalone_workingtree('branch')
44
 
        tree.commit('1', rev_id=b'1', allow_pointless=True)
 
42
        tree.commit('1', rev_id='1', allow_pointless=True)
45
43
        self.build_tree(['branch/added_in_2'])
46
44
        tree.add('added_in_2')
47
 
        tree.commit('2', rev_id=b'2')
 
45
        tree.commit('2', rev_id='2')
48
46
 
49
47
    def test_checkout_makes_bound_branch(self):
50
48
        self.run_bzr('checkout branch checkout')
51
49
        # if we have a checkout, the branch base should be 'branch'
52
50
        source = controldir.ControlDir.open('branch')
53
51
        result = controldir.ControlDir.open('checkout')
54
 
        self.assertEqual(source.open_branch().controldir.root_transport.base,
 
52
        self.assertEqual(source.open_branch().bzrdir.root_transport.base,
55
53
                         result.open_branch().get_bound_location())
56
54
 
57
55
    def test_checkout_light_makes_checkout(self):
59
57
        # if we have a checkout, the branch base should be 'branch'
60
58
        source = controldir.ControlDir.open('branch')
61
59
        result = controldir.ControlDir.open('checkout')
62
 
        self.assertEqual(source.open_branch().controldir.root_transport.base,
63
 
                         result.open_branch().controldir.root_transport.base)
 
60
        self.assertEqual(source.open_branch().bzrdir.root_transport.base,
 
61
                         result.open_branch().bzrdir.root_transport.base)
64
62
 
65
63
    def test_checkout_dash_r(self):
66
64
        out, err = self.run_bzr(['checkout', '-r', '-2', 'branch', 'checkout'])
71
69
        self.assertPathDoesNotExist('checkout/added_in_2')
72
70
 
73
71
    def test_checkout_light_dash_r(self):
74
 
        out, err = self.run_bzr(['checkout', '--lightweight', '-r', '-2',
 
72
        out, err = self.run_bzr(['checkout','--lightweight', '-r', '-2',
75
73
            'branch', 'checkout'])
76
74
        # the working tree should now be at revision '1' with the content
77
75
        # from 1.
80
78
        self.assertPathDoesNotExist('checkout/added_in_2')
81
79
 
82
80
    def test_checkout_into_empty_dir(self):
83
 
        self.make_controldir('checkout')
 
81
        self.make_bzrdir('checkout')
84
82
        out, err = self.run_bzr(['checkout', 'branch', 'checkout'])
85
83
        result = controldir.ControlDir.open('checkout')
86
84
        tree = result.open_workingtree()
87
85
        branch = result.open_branch()
88
86
 
89
87
    def test_checkout_reconstitutes_working_trees(self):
90
 
        # doing a 'brz checkout' in the directory of a branch with no tree
91
 
        # or a 'brz checkout path' with path the name of a directory with
 
88
        # doing a 'bzr checkout' in the directory of a branch with no tree
 
89
        # or a 'bzr checkout path' with path the name of a directory with
92
90
        # a branch with no tree will reconsistute the tree.
93
91
        os.mkdir('treeless-branch')
94
92
        branch = controldir.ControlDir.create_branch_convenience(
96
94
            force_new_tree=False,
97
95
            format=bzrdir.BzrDirMetaFormat1())
98
96
        # check no tree was created
99
 
        self.assertRaises(errors.NoWorkingTree, branch.controldir.open_workingtree)
 
97
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
100
98
        out, err = self.run_bzr('checkout treeless-branch')
101
99
        # we should have a tree now
102
 
        branch.controldir.open_workingtree()
 
100
        branch.bzrdir.open_workingtree()
103
101
        # with no diff
104
102
        out, err = self.run_bzr('diff treeless-branch')
105
103
 
109
107
            force_new_tree=False,
110
108
            format=bzrdir.BzrDirMetaFormat1())
111
109
        # check no tree was created
112
 
        self.assertRaises(errors.NoWorkingTree, branch.controldir.open_workingtree)
 
110
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
113
111
        out, err = self.run_bzr('checkout')
114
112
        # we should have a tree now
115
 
        branch.controldir.open_workingtree()
 
113
        branch.bzrdir.open_workingtree()
116
114
        # with no diff
117
115
        out, err = self.run_bzr('diff')
118
116
 
119
117
    def _test_checkout_existing_dir(self, lightweight):
120
118
        source = self.make_branch_and_tree('source')
121
 
        self.build_tree_contents([('source/file1', b'content1'),
122
 
                                  ('source/file2', b'content2'),])
 
119
        self.build_tree_contents([('source/file1', 'content1'),
 
120
                                  ('source/file2', 'content2'),])
123
121
        source.add(['file1', 'file2'])
124
122
        source.commit('added files')
125
 
        self.build_tree_contents([('target/', b''),
126
 
                                  ('target/file1', b'content1'),
127
 
                                  ('target/file2', b'content3'),])
 
123
        self.build_tree_contents([('target/', ''),
 
124
                                  ('target/file1', 'content1'),
 
125
                                  ('target/file2', 'content3'),])
128
126
        cmd = ['checkout', 'source', 'target']
129
127
        if lightweight:
130
128
            cmd.append('--lightweight')
142
140
 
143
141
    def test_checkout_in_branch_with_r(self):
144
142
        branch = _mod_branch.Branch.open('branch')
145
 
        branch.controldir.destroy_workingtree()
 
143
        branch.bzrdir.destroy_workingtree()
146
144
        self.run_bzr('checkout -r 1', working_dir='branch')
147
145
        tree = workingtree.WorkingTree.open('branch')
148
146
        self.assertEqual('1', tree.last_revision())
149
 
        branch.controldir.destroy_workingtree()
 
147
        branch.bzrdir.destroy_workingtree()
150
148
        self.run_bzr('checkout -r 0', working_dir='branch')
151
149
        self.assertEqual('null:', tree.last_revision())
152
150
 
172
170
        self.build_tree(['source/file1'])
173
171
        source.add('file1')
174
172
        source.commit('added file')
175
 
        source.controldir.sprout('second')
 
173
        source.bzrdir.sprout('second')
176
174
        out, err = self.run_bzr('checkout source target --hardlink'
177
175
                                ' --files-from second')
178
176
        second_stat = os.stat('second/file1')
184
182
        self.build_tree(['source/file1'])
185
183
        source.add('file1')
186
184
        source.commit('added file')
187
 
        target = source.controldir.sprout('file:second,branch=somebranch',
 
185
        target = source.bzrdir.sprout('file:second,branch=somebranch',
188
186
            create_tree_if_local=False)
189
187
        out, err = self.run_bzr('checkout file:,branch=somebranch .',
190
188
            working_dir='second')
191
189
        # We should always be creating a lighweight checkout for colocated
192
190
        # branches.
193
 
        self.assertEqual(
194
 
            target.open_branch(name='somebranch').user_url,
 
191
        self.assertEquals(
 
192
            target.open_branch(name='somebranch').base,
195
193
            target.get_branch_reference(name=""))
196
194
 
197
195