~bzr-pqm/bzr/bzr.dev

5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2006-2011 Canonical Ltd
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
16
17
18
"""Black-box tests for bzr branch."""
19
20
import os
21
4596.2.3 by Lukáš Lalinský
Add tests for various situations
22
from bzrlib import (
23
    branch,
24
    bzrdir,
6207.3.3 by jelmer at samba
Fix tests and the like.
25
    controldir,
4596.2.3 by Lukáš Lalinský
Add tests for various situations
26
    errors,
27
    revision as _mod_revision,
28
    )
2241.1.6 by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and
29
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
30
from bzrlib.tests import TestCaseWithTransport
4580.4.2 by Martin Pool
Add KnownFailure for branch --hardlink
31
from bzrlib.tests import (
5651.5.3 by Andrew Bennetts
Use new fixture in more tests.
32
    fixtures,
5017.3.40 by Vincent Ladeuil
-s bb.test_branch passing
33
    test_server,
4580.4.2 by Martin Pool
Add KnownFailure for branch --hardlink
34
    )
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
35
from bzrlib.tests.features import (
36
    HardlinkFeature,
37
    )
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
38
from bzrlib.tests.blackbox import test_switch
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
39
from bzrlib.tests.matchers import ContainsNoVfsCalls
2485.8.59 by Vincent Ladeuil
Update from review comments.
40
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
5741.3.3 by Martin Pool
Add a blackbox test for deprecation of commands
41
from bzrlib.tests.script import run_script
3696.2.4 by Daniel Watkins
Fixed test to cope with trailing slashes.
42
from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
1711.2.6 by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing
43
from bzrlib.workingtree import WorkingTree
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
44
45
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
46
class TestBranch(TestCaseWithTransport):
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
47
6240.3.1 by Jelmer Vernooij
Name new branches after colocated branches.
48
    def example_branch(self, path='.', format=None):
49
        tree = self.make_branch_and_tree(path, format=format)
2664.8.2 by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate.
50
        self.build_tree_contents([(path + '/hello', 'foo')])
51
        tree.add('hello')
52
        tree.commit(message='setup')
53
        self.build_tree_contents([(path + '/goodbye', 'baz')])
54
        tree.add('goodbye')
55
        tree.commit(message='setup')
6240.3.1 by Jelmer Vernooij
Name new branches after colocated branches.
56
        return tree
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
57
58
    def test_branch(self):
59
        """Branch from one branch to another."""
2664.8.2 by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate.
60
        self.example_branch('a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
61
        self.run_bzr('branch a b')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
62
        b = branch.Branch.open('b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
63
        self.run_bzr('branch a c -r 1')
3400.1.3 by Martin Pool
Merge trunk
64
        # previously was erroneously created by branching
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
65
        self.assertFalse(b._transport.has('branch-name'))
2664.8.2 by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate.
66
        b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
67
6207.2.1 by jelmer at samba
Fix cloning to colocated branch.
68
    def test_into_colocated(self):
69
        """Branch from a branch into a colocated branch."""
70
        self.example_branch('a')
71
        out, err = self.run_bzr(
72
            'init --format=development-colo file:b,branch=orig')
73
        self.assertEqual(
6240.2.12 by Jelmer Vernooij
Fix foreign tests.
74
            """Created a lightweight checkout (format: development-colo)\n""",
6207.2.1 by jelmer at samba
Fix cloning to colocated branch.
75
            out)
76
        self.assertEqual('', err)
77
        out, err = self.run_bzr(
6266.1.1 by Jelmer Vernooij
Support branching into colocated branch.
78
            'branch a file:b,branch=thiswasa')
6207.2.1 by jelmer at samba
Fix cloning to colocated branch.
79
        self.assertEqual('', out)
80
        self.assertEqual('Branched 2 revisions.\n', err)
81
        out, err = self.run_bzr('branches b')
6379.10.3 by Jelmer Vernooij
Only display active branch if it's not one of the existing colocated branches.
82
        self.assertEqual("  orig\n  thiswasa\n", out)
6207.2.1 by jelmer at samba
Fix cloning to colocated branch.
83
        self.assertEqual('', err)
6266.1.1 by Jelmer Vernooij
Support branching into colocated branch.
84
        out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
85
        self.assertEqual('', out)
86
        self.assertEqual('bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
6207.2.1 by jelmer at samba
Fix cloning to colocated branch.
87
6240.3.1 by Jelmer Vernooij
Name new branches after colocated branches.
88
    def test_from_colocated(self):
89
        """Branch from a colocated branch into a regular branch."""
90
        tree = self.example_branch('a', format='development-colo')
91
        tree.bzrdir.create_branch(name='somecolo')
92
        out, err = self.run_bzr('branch %s,branch=somecolo' %
93
            local_path_to_url('a'))
94
        self.assertEqual('', out)
95
        self.assertEqual('Branched 0 revisions.\n', err)
96
        self.assertPathExists("somecolo")
97
5927.2.1 by Jonathan Riddell
start a test case for corrupt pack files
98
    def test_branch_broken_pack(self):
99
        """branching with a corrupted pack file."""
100
        self.example_branch('a')
6158.1.1 by Vincent Ladeuil
Fix random test failure by making the test not random
101
        # add some corruption
102
        packs_dir = 'a/.bzr/repository/packs/'
103
        fname = packs_dir + os.listdir(packs_dir)[0]
5927.2.8 by Jonathan Riddell
tidy up file opening in test
104
        with open(fname, 'rb+') as f:
6158.1.1 by Vincent Ladeuil
Fix random test failure by making the test not random
105
            # Start from the end of the file to avoid choosing a place bigger
106
            # than the file itself.
107
            f.seek(-5, os.SEEK_END)
108
            c = f.read(1)
109
            f.seek(-5, os.SEEK_END)
110
            # Make sure we inject a value different than the one we just read
111
            if c == '\xFF':
112
                corrupt = '\x00'
113
            else:
114
                corrupt = '\xFF'
115
            f.write(corrupt) # make sure we corrupt something
5927.2.6 by Jonathan Riddell
Make error message less specific (might not be a local disk issue) and pass through zlib error
116
        self.run_bzr_error(['Corruption while decompressing repository file'], 
117
                            'branch a b', retcode=3)
5927.2.1 by Jonathan Riddell
start a test case for corrupt pack files
118
4596.2.3 by Lukáš Lalinský
Add tests for various situations
119
    def test_branch_switch_no_branch(self):
120
        # No branch in the current directory:
121
        #  => new branch will be created, but switch fails
122
        self.example_branch('a')
123
        self.make_repository('current')
124
        self.run_bzr_error(['No WorkingTree exists for'],
125
            'branch --switch ../a ../b', working_dir='current')
126
        a = branch.Branch.open('a')
127
        b = branch.Branch.open('b')
128
        self.assertEqual(a.last_revision(), b.last_revision())
129
130
    def test_branch_switch_no_wt(self):
131
        # No working tree in the current directory:
132
        #  => new branch will be created, but switch fails and the current
133
        #     branch is unmodified
134
        self.example_branch('a')
135
        self.make_branch('current')
136
        self.run_bzr_error(['No WorkingTree exists for'],
137
            'branch --switch ../a ../b', working_dir='current')
138
        a = branch.Branch.open('a')
139
        b = branch.Branch.open('b')
140
        self.assertEqual(a.last_revision(), b.last_revision())
141
        work = branch.Branch.open('current')
142
        self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
143
4596.2.1 by Lukáš Lalinský
Add support for `bzr branch --switch`
144
    def test_branch_switch_no_checkout(self):
4596.2.3 by Lukáš Lalinský
Add tests for various situations
145
        # Standalone branch in the current directory:
146
        #  => new branch will be created, but switch fails and the current
147
        #     branch is unmodified
4596.2.1 by Lukáš Lalinský
Add support for `bzr branch --switch`
148
        self.example_branch('a')
4596.2.3 by Lukáš Lalinský
Add tests for various situations
149
        self.make_branch_and_tree('current')
4596.2.1 by Lukáš Lalinský
Add support for `bzr branch --switch`
150
        self.run_bzr_error(['Cannot switch a branch, only a checkout'],
4596.2.3 by Lukáš Lalinský
Add tests for various situations
151
            'branch --switch ../a ../b', working_dir='current')
152
        a = branch.Branch.open('a')
153
        b = branch.Branch.open('b')
154
        self.assertEqual(a.last_revision(), b.last_revision())
155
        work = branch.Branch.open('current')
156
        self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
157
158
    def test_branch_switch_checkout(self):
159
        # Checkout in the current directory:
160
        #  => new branch will be created and checkout bound to the new branch
161
        self.example_branch('a')
162
        self.run_bzr('checkout a current')
163
        out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
164
        a = branch.Branch.open('a')
165
        b = branch.Branch.open('b')
166
        self.assertEqual(a.last_revision(), b.last_revision())
167
        work = WorkingTree.open('current')
168
        self.assertEndsWith(work.branch.get_bound_location(), '/b/')
169
        self.assertContainsRe(err, "Switched to branch: .*/b/")
170
171
    def test_branch_switch_lightweight_checkout(self):
172
        # Lightweight checkout in the current directory:
173
        #  => new branch will be created and lightweight checkout pointed to
174
        #     the new branch
175
        self.example_branch('a')
176
        self.run_bzr('checkout --lightweight a current')
177
        out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
178
        a = branch.Branch.open('a')
179
        b = branch.Branch.open('b')
180
        self.assertEqual(a.last_revision(), b.last_revision())
181
        work = WorkingTree.open('current')
182
        self.assertEndsWith(work.branch.base, '/b/')
4596.2.1 by Lukáš Lalinský
Add support for `bzr branch --switch`
183
        self.assertContainsRe(err, "Switched to branch: .*/b/")
184
1711.2.6 by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing
185
    def test_branch_only_copies_history(self):
186
        # Knit branches should only push the history for the current revision.
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
187
        format = bzrdir.BzrDirMetaFormat1()
1711.2.6 by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing
188
        format.repository_format = RepositoryFormatKnit1()
189
        shared_repo = self.make_repository('repo', format=format, shared=True)
190
        shared_repo.set_make_working_trees(True)
191
192
        def make_shared_tree(path):
193
            shared_repo.bzrdir.root_transport.mkdir(path)
6207.3.3 by jelmer at samba
Fix tests and the like.
194
            controldir.ControlDir.create_branch_convenience('repo/' + path)
1711.2.6 by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing
195
            return WorkingTree.open('repo/' + path)
196
        tree_a = make_shared_tree('a')
197
        self.build_tree(['repo/a/file'])
198
        tree_a.add('file')
199
        tree_a.commit('commit a-1', rev_id='a-1')
200
        f = open('repo/a/file', 'ab')
201
        f.write('more stuff\n')
202
        f.close()
203
        tree_a.commit('commit a-2', rev_id='a-2')
204
205
        tree_b = make_shared_tree('b')
206
        self.build_tree(['repo/b/file'])
207
        tree_b.add('file')
208
        tree_b.commit('commit b-1', rev_id='b-1')
209
210
        self.assertTrue(shared_repo.has_revision('a-1'))
211
        self.assertTrue(shared_repo.has_revision('a-2'))
212
        self.assertTrue(shared_repo.has_revision('b-1'))
213
214
        # Now that we have a repository with shared files, make sure
215
        # that things aren't copied out by a 'branch'
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
216
        self.run_bzr('branch repo/b branch-b')
1711.2.6 by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing
217
        pushed_tree = WorkingTree.open('branch-b')
218
        pushed_repo = pushed_tree.branch.repository
219
        self.assertFalse(pushed_repo.has_revision('a-1'))
220
        self.assertFalse(pushed_repo.has_revision('a-2'))
221
        self.assertTrue(pushed_repo.has_revision('b-1'))
222
3136.1.3 by Aaron Bentley
Implement hard-link support for branch and checkout
223
    def test_branch_hardlink(self):
224
        self.requireFeature(HardlinkFeature)
225
        source = self.make_branch_and_tree('source')
226
        self.build_tree(['source/file1'])
227
        source.add('file1')
228
        source.commit('added file')
4580.4.2 by Martin Pool
Add KnownFailure for branch --hardlink
229
        out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
3136.1.3 by Aaron Bentley
Implement hard-link support for branch and checkout
230
        source_stat = os.stat('source/file1')
231
        target_stat = os.stat('target/file1')
4826.1.3 by Andrew Bennetts
Remove KnownFailure from test_branch_hardlink.
232
        self.assertEqual(source_stat, target_stat)
3136.1.3 by Aaron Bentley
Implement hard-link support for branch and checkout
233
5353.2.2 by John Arbash Meinel
update the test suite.
234
    def test_branch_files_from(self):
235
        source = self.make_branch_and_tree('source')
236
        self.build_tree(['source/file1'])
237
        source.add('file1')
238
        source.commit('added file')
239
        out, err = self.run_bzr('branch source target --files-from source')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
240
        self.assertPathExists('target/file1')
5353.2.2 by John Arbash Meinel
update the test suite.
241
242
    def test_branch_files_from_hardlink(self):
243
        self.requireFeature(HardlinkFeature)
244
        source = self.make_branch_and_tree('source')
245
        self.build_tree(['source/file1'])
246
        source.add('file1')
247
        source.commit('added file')
248
        source.bzrdir.sprout('second')
249
        out, err = self.run_bzr('branch source target --files-from second'
250
                                ' --hardlink')
251
        source_stat = os.stat('source/file1')
252
        second_stat = os.stat('second/file1')
253
        target_stat = os.stat('target/file1')
254
        self.assertNotEqual(source_stat, target_stat)
5353.2.5 by John Arbash Meinel
We need to assert that the --hardlink makes the files the same, not different.
255
        self.assertEqual(second_stat, target_stat)
5353.2.2 by John Arbash Meinel
update the test suite.
256
3696.2.1 by Daniel Watkins
Added test for 'branch --standalone'.
257
    def test_branch_standalone(self):
258
        shared_repo = self.make_repository('repo', shared=True)
259
        self.example_branch('source')
260
        self.run_bzr('branch --standalone source repo/target')
261
        b = branch.Branch.open('repo/target')
262
        expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
3696.2.4 by Daniel Watkins
Fixed test to cope with trailing slashes.
263
        self.assertEqual(strip_trailing_slash(b.repository.base),
264
            strip_trailing_slash(local_path_to_url(expected_repo_path)))
3696.2.1 by Daniel Watkins
Added test for 'branch --standalone'.
265
3983.1.5 by Daniel Watkins
Added blackbox test.
266
    def test_branch_no_tree(self):
267
        self.example_branch('source')
268
        self.run_bzr('branch --no-tree source target')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
269
        self.assertPathDoesNotExist('target/hello')
270
        self.assertPathDoesNotExist('target/goodbye')
3983.1.5 by Daniel Watkins
Added blackbox test.
271
4479.2.1 by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet.
272
    def test_branch_into_existing_dir(self):
273
        self.example_branch('a')
4479.2.2 by Vincent Ladeuil
Fix typos and add NEWS entry.
274
        # existing dir with similar files but no .bzr dir
275
        self.build_tree_contents([('b/',)])
4479.2.1 by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet.
276
        self.build_tree_contents([('b/hello', 'bar')])  # different content
4479.2.2 by Vincent Ladeuil
Fix typos and add NEWS entry.
277
        self.build_tree_contents([('b/goodbye', 'baz')])# same content
278
        # fails without --use-existing-dir
4479.2.1 by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet.
279
        out,err = self.run_bzr('branch a b', retcode=3)
280
        self.assertEqual('', out)
281
        self.assertEqual('bzr: ERROR: Target directory "b" already exists.\n',
282
            err)
283
        # force operation
284
        self.run_bzr('branch a b --use-existing-dir')
285
        # check conflicts
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
286
        self.assertPathExists('b/hello.moved')
287
        self.assertPathDoesNotExist('b/godbye.moved')
4479.2.1 by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet.
288
        # we can't branch into branch
289
        out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
290
        self.assertEqual('', out)
291
        self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
292
4927.3.1 by Ian Clatworthy
branch --bind option
293
    def test_branch_bind(self):
294
        self.example_branch('a')
295
        out, err = self.run_bzr('branch a b --bind')
4948.3.1 by Ian Clatworthy
branch --bind option
296
        self.assertEndsWith(err, "New branch bound to a\n")
4927.3.1 by Ian Clatworthy
branch --bind option
297
        b = branch.Branch.open('b')
298
        self.assertEndsWith(b.get_bound_location(), '/a/')
299
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
300
    def test_branch_with_post_branch_init_hook(self):
301
        calls = []
302
        branch.Branch.hooks.install_named_hook('post_branch_init',
303
            calls.append, None)
304
        self.assertLength(0, calls)
305
        self.example_branch('a')
306
        self.assertLength(1, calls)
307
        self.run_bzr('branch a b')
308
        self.assertLength(2, calls)
309
310
    def test_checkout_with_post_branch_init_hook(self):
311
        calls = []
312
        branch.Branch.hooks.install_named_hook('post_branch_init',
313
            calls.append, None)
314
        self.assertLength(0, calls)
315
        self.example_branch('a')
316
        self.assertLength(1, calls)
317
        self.run_bzr('checkout a b')
318
        self.assertLength(2, calls)
319
320
    def test_lightweight_checkout_with_post_branch_init_hook(self):
321
        calls = []
322
        branch.Branch.hooks.install_named_hook('post_branch_init',
323
            calls.append, None)
324
        self.assertLength(0, calls)
325
        self.example_branch('a')
326
        self.assertLength(1, calls)
327
        self.run_bzr('checkout --lightweight a b')
328
        self.assertLength(2, calls)
329
5535.3.1 by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip.
330
    def test_branch_fetches_all_tags(self):
331
        builder = self.make_branch_builder('source')
5651.5.3 by Andrew Bennetts
Use new fixture in more tests.
332
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
5535.3.1 by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip.
333
        source.tags.set_tag('tag-a', 'rev-2')
6404.1.1 by Vincent Ladeuil
Migrate branch.fetch_tags
334
        source.get_config_stack().set('branch.fetch_tags', True)
5535.3.1 by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip.
335
        # Now source has a tag not in its ancestry.  Make a branch from it.
336
        self.run_bzr('branch source new-branch')
337
        new_branch = branch.Branch.open('new-branch')
338
        # The tag is present, and so is its revision.
339
        self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
340
        new_branch.repository.get_revision('rev-2')
341
3665.2.5 by John Arbash Meinel
Test that we alert the user to the upgrade.
342
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
343
class TestBranchStacked(TestCaseWithTransport):
3575.2.2 by Martin Pool
branch --stacked should force a stacked format
344
    """Tests for branch --stacked"""
345
3517.4.11 by Martin Pool
Improved blackbox tests for stacked branches
346
    def assertRevisionInRepository(self, repo_path, revid):
347
        """Check that a revision is in a repository, disregarding stacking."""
348
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
349
        self.assertTrue(repo.has_revision(revid))
350
351
    def assertRevisionNotInRepository(self, repo_path, revid):
352
        """Check that a revision is not in a repository, disregarding stacking."""
353
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
354
        self.assertFalse(repo.has_revision(revid))
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
355
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
356
    def assertRevisionsInBranchRepository(self, revid_list, branch_path):
357
        repo = branch.Branch.open(branch_path).repository
358
        self.assertEqual(set(revid_list),
359
            repo.has_revisions(revid_list))
360
361
    def test_branch_stacked_branch_not_stacked(self):
362
        """Branching a stacked branch is not stacked by default"""
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
363
        # We have a mainline
364
        trunk_tree = self.make_branch_and_tree('target',
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
365
            format='1.9')
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
366
        trunk_tree.commit('mainline')
3221.20.3 by Ian Clatworthy
shallow -> stacked
367
        # and a branch from it which is stacked
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
368
        branch_tree = self.make_branch_and_tree('branch',
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
369
            format='1.9')
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
370
        branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
371
        # with some work on it
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
372
        work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
373
        work_tree.commit('moar work plz')
374
        work_tree.branch.push(branch_tree.branch)
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
375
        # branching our local branch gives us a new stacked branch pointing at
376
        # mainline.
377
        out, err = self.run_bzr(['branch', 'branch', 'newbranch'])
378
        self.assertEqual('', out)
6143.1.4 by Jonathan Riddell
update tests
379
        self.assertEqual('Branched 2 revisions.\n',
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
380
            err)
3575.2.2 by Martin Pool
branch --stacked should force a stacked format
381
        # it should have preserved the branch format, and so it should be
382
        # capable of supporting stacking, but not actually have a stacked_on
383
        # branch configured
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
384
        self.assertRaises(errors.NotStacked,
385
            bzrdir.BzrDir.open('newbranch').open_branch().get_stacked_on_url)
386
387
    def test_branch_stacked_branch_stacked(self):
388
        """Asking to stack on a stacked branch does work"""
389
        # We have a mainline
390
        trunk_tree = self.make_branch_and_tree('target',
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
391
            format='1.9')
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
392
        trunk_revid = trunk_tree.commit('mainline')
393
        # and a branch from it which is stacked
394
        branch_tree = self.make_branch_and_tree('branch',
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
395
            format='1.9')
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
396
        branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base)
397
        # with some work on it
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
398
        work_tree = trunk_tree.branch.bzrdir.sprout('local').open_workingtree()
399
        branch_revid = work_tree.commit('moar work plz')
400
        work_tree.branch.push(branch_tree.branch)
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
401
        # you can chain branches on from there
402
        out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2'])
403
        self.assertEqual('', out)
3221.20.3 by Ian Clatworthy
shallow -> stacked
404
        self.assertEqual('Created new stacked branch referring to %s.\n' %
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
405
            branch_tree.branch.base, err)
406
        self.assertEqual(branch_tree.branch.base,
407
            branch.Branch.open('branch2').get_stacked_on_url())
408
        branch2_tree = WorkingTree.open('branch2')
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
409
        branch2_revid = work_tree.commit('work on second stacked branch')
410
        work_tree.branch.push(branch2_tree.branch)
3549.1.4 by Martin Pool
Branching a stacked branch should not automatically turn on stacking
411
        self.assertRevisionInRepository('branch2', branch2_revid)
412
        self.assertRevisionsInBranchRepository(
413
            [trunk_revid, branch_revid, branch2_revid],
414
            'branch2')
3221.11.19 by Robert Collins
Branching a shallow branch gets a shallow branch.
415
3221.20.3 by Ian Clatworthy
shallow -> stacked
416
    def test_branch_stacked(self):
3221.11.20 by Robert Collins
Support --shallow on branch.
417
        # We have a mainline
418
        trunk_tree = self.make_branch_and_tree('mainline',
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
419
            format='1.9')
3517.4.11 by Martin Pool
Improved blackbox tests for stacked branches
420
        original_revid = trunk_tree.commit('mainline')
421
        self.assertRevisionInRepository('mainline', original_revid)
3221.20.3 by Ian Clatworthy
shallow -> stacked
422
        # and a branch from it which is stacked
423
        out, err = self.run_bzr(['branch', '--stacked', 'mainline',
3221.20.1 by Ian Clatworthy
tweaks by igc during review
424
            'newbranch'])
3221.11.20 by Robert Collins
Support --shallow on branch.
425
        self.assertEqual('', out)
3221.20.3 by Ian Clatworthy
shallow -> stacked
426
        self.assertEqual('Created new stacked branch referring to %s.\n' %
3221.11.20 by Robert Collins
Support --shallow on branch.
427
            trunk_tree.branch.base, err)
3517.4.11 by Martin Pool
Improved blackbox tests for stacked branches
428
        self.assertRevisionNotInRepository('newbranch', original_revid)
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
429
        new_branch = branch.Branch.open('newbranch')
430
        self.assertEqual(trunk_tree.branch.base, new_branch.get_stacked_on_url())
3221.11.20 by Robert Collins
Support --shallow on branch.
431
3221.15.10 by Robert Collins
Add test that we can stack on a smart server from Jonathan Lange.
432
    def test_branch_stacked_from_smart_server(self):
433
        # We can branch stacking on a smart server
5017.3.40 by Vincent Ladeuil
-s bb.test_branch passing
434
        self.transport_server = test_server.SmartTCPServer_for_testing
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
435
        trunk = self.make_branch('mainline', format='1.9')
3221.15.10 by Robert Collins
Add test that we can stack on a smart server from Jonathan Lange.
436
        out, err = self.run_bzr(
437
            ['branch', '--stacked', self.get_url('mainline'), 'shallow'])
438
3575.2.2 by Martin Pool
branch --stacked should force a stacked format
439
    def test_branch_stacked_from_non_stacked_format(self):
440
        """The origin format doesn't support stacking"""
441
        trunk = self.make_branch('trunk', format='pack-0.92')
442
        out, err = self.run_bzr(
443
            ['branch', '--stacked', 'trunk', 'shallow'])
3665.2.5 by John Arbash Meinel
Test that we alert the user to the upgrade.
444
        # We should notify the user that we upgraded their format
3665.2.6 by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format.
445
        self.assertEqualDiff(
4401.1.3 by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests.
446
            'Source repository format does not support stacking, using format:\n'
3665.2.6 by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format.
447
            '  Packs 5 (adds stacking support, requires bzr 1.6)\n'
4401.1.3 by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests.
448
            'Source branch format does not support stacking, using format:\n'
449
            '  Branch format 7\n'
4634.144.6 by Martin Pool
Branching that does an implicit conversion now shows the fetch warning
450
            'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
451
            'This may take some time. Upgrade the repositories to the same format for better performance.\n'
3665.2.6 by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format.
452
            'Created new stacked branch referring to %s.\n' % (trunk.base,),
453
            err)
454
455
    def test_branch_stacked_from_rich_root_non_stackable(self):
456
        trunk = self.make_branch('trunk', format='rich-root-pack')
457
        out, err = self.run_bzr(
458
            ['branch', '--stacked', 'trunk', 'shallow'])
459
        # We should notify the user that we upgraded their format
460
        self.assertEqualDiff(
4401.1.3 by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests.
461
            'Source repository format does not support stacking, using format:\n'
3665.2.6 by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format.
462
            '  Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
4401.1.3 by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests.
463
            'Source branch format does not support stacking, using format:\n'
464
            '  Branch format 7\n'
4634.144.6 by Martin Pool
Branching that does an implicit conversion now shows the fetch warning
465
            'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
466
            'This may take some time. Upgrade the repositories to the same format for better performance.\n'
3665.2.6 by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format.
467
            'Created new stacked branch referring to %s.\n' % (trunk.base,),
468
            err)
469
3575.2.2 by Martin Pool
branch --stacked should force a stacked format
470
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
471
class TestSmartServerBranching(TestCaseWithTransport):
4060.1.1 by Robert Collins
Add ratcheted acceptance test for branching from a smart server.
472
4060.1.4 by Robert Collins
Streaming fetch from remote servers.
473
    def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
474
        self.setup_smart_server_with_call_log()
475
        t = self.make_branch_and_tree('from')
476
        for count in range(9):
477
            t.commit(message='commit %d' % count)
478
        self.reset_smart_call_log()
479
        out, err = self.run_bzr(['branch', self.get_url('from'),
480
            self.get_url('target')])
481
        # This figure represent the amount of work to perform this use case. It
482
        # is entirely ok to reduce this number if a test fails due to rpc_count
483
        # being too low. If rpc_count increases, more network roundtrips have
484
        # become necessary for this use case. Please do not adjust this number
485
        # upwards without agreement from bzr's network support maintainers.
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
486
        self.assertLength(2, self.hpss_connections)
6282.6.11 by Jelmer Vernooij
Adjust some call counts.
487
        self.assertLength(33, self.hpss_calls)
6352.2.2 by Jelmer Vernooij
Use new NoVfsCalls matcher in blackbox tests.
488
        self.expectFailure("branching to the same branch requires VFS access",
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
489
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
4060.1.4 by Robert Collins
Streaming fetch from remote servers.
490
4060.1.1 by Robert Collins
Add ratcheted acceptance test for branching from a smart server.
491
    def test_branch_from_trivial_branch_streaming_acceptance(self):
492
        self.setup_smart_server_with_call_log()
493
        t = self.make_branch_and_tree('from')
494
        for count in range(9):
495
            t.commit(message='commit %d' % count)
496
        self.reset_smart_call_log()
4060.1.2 by Robert Collins
Get RemoteToOther inter repository logic using the generic fetch code, to permit eventual streaming from smart servers.
497
        out, err = self.run_bzr(['branch', self.get_url('from'),
498
            'local-target'])
4060.1.1 by Robert Collins
Add ratcheted acceptance test for branching from a smart server.
499
        # This figure represent the amount of work to perform this use case. It
500
        # is entirely ok to reduce this number if a test fails due to rpc_count
501
        # being too low. If rpc_count increases, more network roundtrips have
502
        # become necessary for this use case. Please do not adjust this number
503
        # upwards without agreement from bzr's network support maintainers.
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
504
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
6015.15.3 by John Arbash Meinel
More cases that show the extra RPC
505
        self.assertLength(10, self.hpss_calls)
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
506
        self.assertLength(1, self.hpss_connections)
4060.1.1 by Robert Collins
Add ratcheted acceptance test for branching from a smart server.
507
4152.1.2 by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so.
508
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
509
        self.setup_smart_server_with_call_log()
510
        t = self.make_branch_and_tree('trunk')
511
        for count in range(8):
512
            t.commit(message='commit %d' % count)
513
        tree2 = t.branch.bzrdir.sprout('feature', stacked=True
514
            ).open_workingtree()
4595.4.1 by Robert Collins
Fix test_branch_from_trivial_stacked_branch_streaming_acceptance to work with rich root formats, pending work on bug 375013.
515
        local_tree = t.branch.bzrdir.sprout('local-working').open_workingtree()
516
        local_tree.commit('feature change')
517
        local_tree.branch.push(tree2.branch)
4152.1.2 by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so.
518
        self.reset_smart_call_log()
519
        out, err = self.run_bzr(['branch', self.get_url('feature'),
520
            'local-target'])
521
        # This figure represent the amount of work to perform this use case. It
522
        # is entirely ok to reduce this number if a test fails due to rpc_count
523
        # being too low. If rpc_count increases, more network roundtrips have
524
        # become necessary for this use case. Please do not adjust this number
525
        # upwards without agreement from bzr's network support maintainers.
6015.15.3 by John Arbash Meinel
More cases that show the extra RPC
526
        self.assertLength(15, self.hpss_calls)
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
527
        self.assertLength(1, self.hpss_connections)
6282.6.42 by Jelmer Vernooij
merge hpss-get-checkout-format.
528
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
4152.1.2 by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so.
529
5535.4.7 by Andrew Bennetts
Add HPSS acceptance test.
530
    def test_branch_from_branch_with_tags(self):
531
        self.setup_smart_server_with_call_log()
532
        builder = self.make_branch_builder('source')
5651.5.3 by Andrew Bennetts
Use new fixture in more tests.
533
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
6404.1.1 by Vincent Ladeuil
Migrate branch.fetch_tags
534
        source.get_config_stack().set('branch.fetch_tags', True)
5535.4.7 by Andrew Bennetts
Add HPSS acceptance test.
535
        source.tags.set_tag('tag-a', 'rev-2')
536
        source.tags.set_tag('tag-missing', 'missing-rev')
537
        # Now source has a tag not in its ancestry.  Make a branch from it.
538
        self.reset_smart_call_log()
539
        out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
540
        # This figure represent the amount of work to perform this use case. It
541
        # is entirely ok to reduce this number if a test fails due to rpc_count
542
        # being too low. If rpc_count increases, more network roundtrips have
543
        # become necessary for this use case. Please do not adjust this number
544
        # upwards without agreement from bzr's network support maintainers.
6015.15.2 by John Arbash Meinel
This adds one more hpss round trip to determine the configuration setting.
545
        self.assertLength(10, self.hpss_calls)
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
546
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
547
        self.assertLength(1, self.hpss_connections)
5535.4.7 by Andrew Bennetts
Add HPSS acceptance test.
548
5816.8.1 by Andrew Bennetts
Be a little more clever about constructing a parents provider for stacked repositories, so that get_parent_map with local-stacked-on-remote doesn't use HPSS VFS calls.
549
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
550
        self.setup_smart_server_with_call_log()
551
        t = self.make_branch_and_tree('from')
552
        for count in range(9):
553
            t.commit(message='commit %d' % count)
554
        self.reset_smart_call_log()
555
        out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
556
            'local-target'])
5816.8.6 by Andrew Bennetts
Fix another bug, and some cosmetic nits.
557
        # XXX: the number of hpss calls for this case isn't deterministic yet,
5816.8.1 by Andrew Bennetts
Be a little more clever about constructing a parents provider for stacked repositories, so that get_parent_map with local-stacked-on-remote doesn't use HPSS VFS calls.
558
        # so we can't easily assert about the number of calls.
559
        #self.assertLength(XXX, self.hpss_calls)
560
        # We can assert that none of the calls were readv requests for rix
561
        # files, though (demonstrating that at least get_parent_map calls are
562
        # not using VFS RPCs).
563
        readvs_of_rix_files = [
564
            c for c in self.hpss_calls
565
            if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
566
        self.assertLength(1, self.hpss_connections)
5816.8.1 by Andrew Bennetts
Be a little more clever about constructing a parents provider for stacked repositories, so that get_parent_map with local-stacked-on-remote doesn't use HPSS VFS calls.
567
        self.assertLength(0, readvs_of_rix_files)
6352.2.2 by Jelmer Vernooij
Use new NoVfsCalls matcher in blackbox tests.
568
        self.expectFailure("branching to stacked requires VFS access",
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
569
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
5816.8.1 by Andrew Bennetts
Be a little more clever about constructing a parents provider for stacked repositories, so that get_parent_map with local-stacked-on-remote doesn't use HPSS VFS calls.
570
1711.2.5 by John Arbash Meinel
Factoring blackbox tests into their own file.
571
2485.8.59 by Vincent Ladeuil
Update from review comments.
572
class TestRemoteBranch(TestCaseWithSFTPServer):
573
574
    def setUp(self):
575
        super(TestRemoteBranch, self).setUp()
576
        tree = self.make_branch_and_tree('branch')
577
        self.build_tree_contents([('branch/file', 'file content\n')])
578
        tree.add('file')
579
        tree.commit('file created')
580
581
    def test_branch_local_remote(self):
582
        self.run_bzr(['branch', 'branch', self.get_url('remote')])
583
        t = self.get_transport()
2485.8.62 by Vincent Ladeuil
From review comments, fix typos and deprecate some functions.
584
        # Ensure that no working tree what created remotely
2485.8.59 by Vincent Ladeuil
Update from review comments.
585
        self.assertFalse(t.has('remote/file'))
586
587
    def test_branch_remote_remote(self):
588
        # Light cheat: we access the branch remotely
589
        self.run_bzr(['branch', self.get_url('branch'),
590
                      self.get_url('remote')])
591
        t = self.get_transport()
2485.8.62 by Vincent Ladeuil
From review comments, fix typos and deprecate some functions.
592
        # Ensure that no working tree what created remotely
2485.8.59 by Vincent Ladeuil
Update from review comments.
593
        self.assertFalse(t.has('remote/file'))
594
5741.3.3 by Martin Pool
Add a blackbox test for deprecation of commands
595
596
class TestDeprecatedAliases(TestCaseWithTransport):
597
598
    def test_deprecated_aliases(self):
599
        """bzr branch can be called clone or get, but those names are deprecated.
600
601
        See bug 506265.
602
        """
603
        for command in ['clone', 'get']:
604
            run_script(self, """
605
            $ bzr %(command)s A B
606
            2>The command 'bzr %(command)s' has been deprecated in bzr 2.4. Please use 'bzr branch' instead.
607
            2>bzr: ERROR: Not a branch...
608
            """ % locals())
5816.6.7 by A. S. Budden
Moved test harnesses into test_switch and test_branch as these are the commands that are being tested.
609
610
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
611
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
612
613
    def _checkout_and_branch(self, option=''):
614
        self.script_runner.run_script(self, '''
615
                $ bzr checkout %(option)s repo/trunk checkout
616
                $ cd checkout
617
                $ bzr branch --switch ../repo/trunk ../repo/branched
6143.1.4 by Jonathan Riddell
update tests
618
                2>Branched 0 revisions.
5816.6.8 by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight.
619
                2>Tree is up to date at revision 0.
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
620
                2>Switched to branch:...branched...
5816.6.11 by A. S. Budden
Refactored assertParentCorrect to check the full path.
621
                $ cd ..
5816.6.10 by A. S. Budden
Use locals() instead of kwargs for more explicit parameters.
622
                ''' % locals())
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
623
        bound_branch = branch.Branch.open_containing('checkout')[0]
624
        master_branch = branch.Branch.open_containing('repo/branched')[0]
5816.6.12 by A. S. Budden
Check parent branch of both the checkout (light or heavy) and the branch to which it is connected.
625
        return (bound_branch, master_branch)
5816.6.8 by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight.
626
5816.6.7 by A. S. Budden
Moved test harnesses into test_switch and test_branch as these are the commands that are being tested.
627
    def test_branch_switch_parent_lightweight(self):
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
628
        """Lightweight checkout using bzr branch --switch."""
629
        bb, mb = self._checkout_and_branch(option='--lightweight')
630
        self.assertParent('repo/trunk', bb)
631
        self.assertParent('repo/trunk', mb)
5816.6.7 by A. S. Budden
Moved test harnesses into test_switch and test_branch as these are the commands that are being tested.
632
633
    def test_branch_switch_parent_heavyweight(self):
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
634
        """Heavyweight checkout using bzr branch --switch."""
635
        bb, mb = self._checkout_and_branch()
636
        self.assertParent('repo/trunk', bb)
637
        self.assertParent('repo/trunk', mb)