129
136
"""Using switch on a heavy checkout should find master sibling
131
138
The behaviour of lighweight and heavy checkouts should be
132
consistentwhen using the convenient "switch to sibling" feature
139
consistent when using the convenient "switch to sibling" feature
133
140
Both should switch to a sibling of the branch
134
141
they are bound to, and not a sibling of themself"""
270
277
self.run_bzr('checkout --lightweight a checkout')
271
278
self.run_bzr('switch --directory checkout b')
272
279
self.assertFileEqual('initial\nmore\n', 'checkout/a')
281
class TestSwitchParentLocationBase(TestCaseWithTransport):
284
"""Set up a repository and branch ready for testing."""
285
super(TestSwitchParentLocationBase, self).setUp()
286
self.script_runner = script.ScriptRunner()
287
self.script_runner.run_script(self, '''
288
$ bzr init-repo --no-trees repo
291
shared repository: repo
292
$ bzr init repo/trunk
293
Created a repository branch...
294
Using shared repository: ...
297
def assertParent(self, expected_parent, branch):
298
"""Verify that the parent is not None and is set correctly."""
299
actual_parent = branch.get_parent()
300
self.assertIsSameRealPath(urlutils.local_path_to_url(expected_parent),
304
class TestSwitchParentLocation(TestSwitchParentLocationBase):
306
def _checkout_and_switch(self, option=''):
307
self.script_runner.run_script(self, '''
308
$ bzr checkout %(option)s repo/trunk checkout
310
$ bzr switch --create-branch switched
311
2>Tree is up to date at revision 0.
312
2>Switched to branch:...switched...
315
bound_branch = branch.Branch.open_containing('checkout')[0]
316
master_branch = branch.Branch.open_containing('repo/switched')[0]
317
return (bound_branch, master_branch)
319
def test_switch_parent_lightweight(self):
320
"""Lightweight checkout using bzr switch."""
321
bb, mb = self._checkout_and_switch(option='--lightweight')
322
self.assertParent('repo/trunk', bb)
323
self.assertParent('repo/trunk', mb)
325
def test_switch_parent_heavyweight(self):
326
"""Heavyweight checkout using bzr switch."""
327
bb, mb = self._checkout_and_switch()
328
self.assertParent('repo/trunk', bb)
329
self.assertParent('repo/trunk', mb)