/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_reconfigure.py

  • Committer: Jelmer Vernooij
  • Date: 2018-07-08 14:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 7036.
  • Revision ID: jelmer@jelmer.uk-20180708144527-codhlvdcdg9y0nji
Fix a bunch of merge tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2007-2012, 2016 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib import (
18
 
    bzrdir,
 
17
from breezy import (
 
18
    controldir,
19
19
    errors,
20
20
    tests,
21
21
    workingtree,
22
22
    )
23
 
from bzrlib.branchbuilder import BranchBuilder
24
 
 
25
 
 
26
 
class TestReconfigure(tests.TestCaseWithTransport):
 
23
from breezy.tests.script import TestCaseWithTransportAndScript
 
24
 
 
25
 
 
26
class TestReconfigure(TestCaseWithTransportAndScript):
27
27
 
28
28
    def test_no_type(self):
29
29
        branch = self.make_branch('branch')
30
 
        self.run_bzr_error(['No target configuration specified'],
 
30
        self.run_bzr_error([b'No target configuration specified'],
31
31
                           'reconfigure branch')
32
32
 
33
33
    def test_branch_to_tree(self):
50
50
        tree = self.make_branch_and_tree('tree')
51
51
        self.build_tree(['tree/file'])
52
52
        tree.add('file')
53
 
        self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
 
53
        self.run_bzr_error([b'Working tree ".*" has uncommitted changes'],
54
54
                            'reconfigure --branch tree')
55
55
        self.run_bzr('reconfigure --force --branch tree')
56
56
 
66
66
 
67
67
    def test_no_args(self):
68
68
        branch = self.make_branch('branch')
69
 
        self.run_bzr_error(['No target configuration specified'],
 
69
        self.run_bzr_error([b'No target configuration specified'],
70
70
                           'reconfigure', working_dir='branch')
71
71
 
72
72
    def test_checkout_to_lightweight_checkout(self):
80
80
        repo = self.make_repository('repo', shared=True)
81
81
        self.run_bzr('reconfigure --use-shared', working_dir='repo/tree')
82
82
        tree = workingtree.WorkingTree.open('repo/tree')
83
 
        self.assertNotEqual(tree.bzrdir.root_transport.base,
84
 
            tree.branch.repository.bzrdir.root_transport.base)
 
83
        self.assertNotEqual(tree.controldir.root_transport.base,
 
84
            tree.branch.repository.controldir.root_transport.base)
85
85
 
86
86
    def test_use_shared_to_standalone(self):
87
87
        repo = self.make_repository('repo', shared=True)
88
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
89
 
        self.assertNotEqual(branch.bzrdir.root_transport.base,
90
 
            branch.repository.bzrdir.root_transport.base)
 
88
        branch = controldir.ControlDir.create_branch_convenience('repo/tree')
 
89
        self.assertNotEqual(branch.controldir.root_transport.base,
 
90
            branch.repository.controldir.root_transport.base)
91
91
        self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
92
92
        tree = workingtree.WorkingTree.open('repo/tree')
93
 
        self.assertEqual(tree.bzrdir.root_transport.base,
94
 
            tree.branch.repository.bzrdir.root_transport.base)
 
93
        self.assertEqual(tree.controldir.root_transport.base,
 
94
            tree.branch.repository.controldir.root_transport.base)
95
95
 
96
96
    def test_make_with_trees(self):
97
97
        repo = self.make_repository('repo', shared=True)
102
102
    def test_make_with_trees_already_trees(self):
103
103
        repo = self.make_repository('repo', shared=True)
104
104
        repo.set_make_working_trees(True)
105
 
        self.run_bzr_error([" already creates working trees"],
 
105
        self.run_bzr_error([b" already creates working trees"],
106
106
                            'reconfigure --with-trees repo')
107
107
 
108
108
    def test_make_without_trees(self):
114
114
    def test_make_without_trees_already_no_trees(self):
115
115
        repo = self.make_repository('repo', shared=True)
116
116
        repo.set_make_working_trees(False)
117
 
        self.run_bzr_error([" already doesn't create working trees"],
 
117
        self.run_bzr_error([b" already doesn't create working trees"],
118
118
                            'reconfigure --with-no-trees repo')
119
119
 
120
120
    def test_make_with_trees_nonshared_repo(self):
121
121
        branch = self.make_branch('branch')
122
122
        self.run_bzr_error(
123
 
            ["Requested reconfiguration of '.*' is not supported"],
 
123
            [b"Requested reconfiguration of '.*' is not supported"],
124
124
            'reconfigure --with-trees branch')
125
125
 
126
126
    def test_make_without_trees_leaves_tree_alone(self):
127
127
        repo = self.make_repository('repo', shared=True)
128
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
 
128
        branch = controldir.ControlDir.create_branch_convenience('repo/branch')
129
129
        tree = workingtree.WorkingTree.open('repo/branch')
130
130
        self.build_tree(['repo/branch/foo'])
131
131
        tree.add('foo')
132
132
        self.run_bzr('reconfigure --with-no-trees --force',
133
133
            working_dir='repo/branch')
134
 
        self.failUnlessExists('repo/branch/foo')
 
134
        self.assertPathExists('repo/branch/foo')
135
135
        tree = workingtree.WorkingTree.open('repo/branch')
136
136
 
137
137
    def test_shared_format_to_standalone(self, format=None):
138
138
        repo = self.make_repository('repo', shared=True, format=format)
139
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
140
 
        self.assertNotEqual(branch.bzrdir.root_transport.base,
141
 
            branch.repository.bzrdir.root_transport.base)
 
139
        branch = controldir.ControlDir.create_branch_convenience('repo/tree')
 
140
        self.assertNotEqual(branch.controldir.root_transport.base,
 
141
            branch.repository.controldir.root_transport.base)
142
142
        tree = workingtree.WorkingTree.open('repo/tree')
143
 
        self.build_tree_contents([('repo/tree/file', 'foo\n')]);
 
143
        self.build_tree_contents([('repo/tree/file', b'foo\n')]);
144
144
        tree.add(['file'])
145
145
        tree.commit('added file')
146
146
        self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
147
147
        tree = workingtree.WorkingTree.open('repo/tree')
148
 
        self.build_tree_contents([('repo/tree/file', 'bar\n')]);
149
 
        self.check_file_contents('repo/tree/file', 'bar\n')
 
148
        self.build_tree_contents([('repo/tree/file', b'bar\n')]);
 
149
        self.check_file_contents('repo/tree/file', b'bar\n')
150
150
        self.run_bzr('revert', working_dir='repo/tree')
151
 
        self.check_file_contents('repo/tree/file', 'foo\n')
152
 
        self.assertEqual(tree.bzrdir.root_transport.base,
153
 
            tree.branch.repository.bzrdir.root_transport.base)
 
151
        self.check_file_contents('repo/tree/file', b'foo\n')
 
152
        self.assertEqual(tree.controldir.root_transport.base,
 
153
            tree.branch.repository.controldir.root_transport.base)
154
154
 
155
155
    def test_shared_knit_to_standalone(self):
156
156
        self.test_shared_format_to_standalone('knit')
165
165
        branch = self.make_branch('branch', format=format)
166
166
        checkout = branch.create_checkout('checkout', lightweight=True)
167
167
        tree = workingtree.WorkingTree.open('checkout')
168
 
        self.build_tree_contents([('checkout/file', 'foo\n')]);
 
168
        self.build_tree_contents([('checkout/file', b'foo\n')]);
169
169
        tree.add(['file'])
170
170
        tree.commit('added file')
171
171
        self.run_bzr('reconfigure --tree', working_dir='checkout')
172
172
        tree = workingtree.WorkingTree.open('checkout')
173
 
        self.build_tree_contents([('checkout/file', 'bar\n')]);
174
 
        self.check_file_contents('checkout/file', 'bar\n')
 
173
        self.build_tree_contents([('checkout/file', b'bar\n')]);
 
174
        self.check_file_contents('checkout/file', b'bar\n')
175
175
        self.run_bzr('revert', working_dir='checkout')
176
 
        self.check_file_contents('checkout/file', 'foo\n')
 
176
        self.check_file_contents('checkout/file', b'foo\n')
177
177
 
178
 
    def test_lightweight_knit_checkout_to_tree(self, format=None):
 
178
    def test_lightweight_knit_checkout_to_tree(self):
179
179
        self.test_lightweight_format_checkout_to_tree('knit')
180
180
 
181
 
    def test_lightweight_pack092_checkout_to_tree(self, format=None):
 
181
    def test_lightweight_pack092_checkout_to_tree(self):
182
182
        self.test_lightweight_format_checkout_to_tree('pack-0.92')
183
183
 
184
 
    def test_lightweight_rich_root_pack_checkout_to_tree(self, format=None):
 
184
    def test_lightweight_rich_root_pack_checkout_to_tree(self):
185
185
        self.test_lightweight_format_checkout_to_tree('rich-root-pack')
186
186
 
 
187
    def test_branch_and_use_shared(self):
 
188
        self.run_script("""\
 
189
$ brz init -q branch
 
190
$ echo foo > branch/foo
 
191
$ brz add -q branch/foo
 
192
$ brz commit -q -m msg branch
 
193
$ brz init-repo -q .
 
194
$ brz reconfigure --branch --use-shared branch
 
195
$ brz info branch
 
196
Repository branch (format: ...)
 
197
Location:
 
198
  shared repository: .
 
199
  repository branch: branch
 
200
""")
 
201
 
 
202
    def test_use_shared_and_branch(self):
 
203
        self.run_script("""\
 
204
$ brz init -q branch
 
205
$ echo foo > branch/foo
 
206
$ brz add -q branch/foo
 
207
$ brz commit -q -m msg branch
 
208
$ brz init-repo -q .
 
209
$ brz reconfigure --use-shared --branch branch
 
210
$ brz info branch
 
211
Repository branch (format: ...)
 
212
Location:
 
213
  shared repository: .
 
214
  repository branch: branch
 
215
""")
 
216
 
187
217
 
188
218
class TestReconfigureStacking(tests.TestCaseWithTransport):
189
219
 
197
227
         * then make the second unstacked, so it has to fill in history from
198
228
           the original fallback lying underneath its original content
199
229
 
200
 
        See discussion in <https://bugs.edge.launchpad.net/bzr/+bug/391411>
 
230
        See discussion in <https://bugs.launchpad.net/bzr/+bug/391411>
201
231
        """
202
232
        # there are also per_branch tests that exercise remote operation etc
203
233
        tree_1 = self.make_branch_and_tree('b1', format='2a')
206
236
        tree_1.commit('add foo')
207
237
        branch_1 = tree_1.branch
208
238
        # now branch and commit again
209
 
        bzrdir_2 = tree_1.bzrdir.sprout('b2')
 
239
        bzrdir_2 = tree_1.controldir.sprout('b2')
210
240
        tree_2 = bzrdir_2.open_workingtree()
211
241
        branch_2 = tree_2.branch
212
242
        # now reconfigure to be stacked
213
243
        out, err = self.run_bzr('reconfigure --stacked-on b1 b2')
214
 
        self.assertContainsRe(out,
215
 
            '^.*/b2/ is now stacked on ../b1\n$')
216
 
        self.assertEquals('', err)
 
244
        self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
 
245
        self.assertEqual(b'', err)
217
246
        # can also give the absolute URL of the branch, and it gets stored 
218
247
        # as a relative path if possible
219
248
        out, err = self.run_bzr('reconfigure --stacked-on %s b2'
220
 
            % (self.get_url('b1'),))
221
 
        self.assertContainsRe(out,
222
 
            '^.*/b2/ is now stacked on ../b1\n$')
223
 
        self.assertEquals('', err)
 
249
                                % (self.get_url('b1'),))
 
250
        self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
 
251
        self.assertEqual(b'', err)
 
252
        # Refresh the branch as 'reconfigure' modified it
 
253
        branch_2 = branch_2.controldir.open_branch()
224
254
        # It should be given a relative URL to the destination, if possible,
225
255
        # because that's most likely to work across different transports
226
 
        self.assertEquals(branch_2.get_stacked_on_url(),
227
 
            '../b1')
 
256
        self.assertEqual('../b1', branch_2.get_stacked_on_url())
228
257
        # commit, and it should be stored into b2's repo
229
 
        self.build_tree_contents([('foo', 'new foo')])
 
258
        self.build_tree_contents([('foo', b'new foo')])
230
259
        tree_2.commit('update foo')
231
260
        # Now turn it off again
232
261
        out, err = self.run_bzr('reconfigure --unstacked b2')
233
262
        self.assertContainsRe(out,
234
263
            '^.*/b2/ is now not stacked\n$')
235
 
        self.assertEquals('', err)
236
 
        self.assertRaises(errors.NotStacked,
237
 
            branch_2.get_stacked_on_url)
 
264
        self.assertEqual(b'', err)
 
265
        # Refresh the branch as 'reconfigure' modified it
 
266
        branch_2 = branch_2.controldir.open_branch()
 
267
        self.assertRaises(errors.NotStacked, branch_2.get_stacked_on_url)
238
268
 
239
269
    # XXX: Needs a test for reconfiguring stacking and shape at the same time;
240
270
    # no branch at location; stacked-on is not a branch; quiet mode.