/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2007-2012, 2016 Canonical Ltd
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
2
# -*- coding: utf-8 -*-
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
17
18
19
"""Tests for the switch command of bzr."""
20
21
import os
22
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy.controldir import ControlDir
24
from breezy import (
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
25
    osutils,
26
    urlutils,
27
    branch,
28
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
29
from breezy.workingtree import WorkingTree
30
from breezy.tests import (
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
31
    TestCaseWithTransport,
32
    script,
33
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
34
from breezy.tests.features import UnicodeFilenameFeature
35
from breezy.directory_service import directories
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
36
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
37
from breezy.tests.matchers import ContainsNoVfsCalls
6366.1.5 by Jelmer Vernooij
add test for hpss call / connection count of 'bzr switch'.
38
5816.6.15 by A. S. Budden
Added erroneously removed blank line.
39
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
40
class TestSwitch(TestCaseWithTransport):
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
41
3984.5.14 by Daniel Watkins
Extracted common setup code.
42
    def _create_sample_tree(self):
43
        tree = self.make_branch_and_tree('branch-1')
44
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
45
        tree.add('file-1')
46
        tree.commit('rev1')
47
        tree.add('file-2')
48
        tree.commit('rev2')
49
        return tree
50
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
51
    def test_switch_up_to_date_light_checkout(self):
52
        self.make_branch_and_tree('branch')
53
        self.run_bzr('branch branch branch2')
54
        self.run_bzr('checkout --lightweight branch checkout')
55
        os.chdir('checkout')
56
        out, err = self.run_bzr('switch ../branch2')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
57
        self.assertContainsRe(err, 'Tree is up to date at revision 0.\n')
7223.1.1 by Jelmer Vernooij
Display colocated branch name without full path when switching between colocated branches.
58
        self.assertContainsRe(err, 'Switched to branch at .*/branch2.\n')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
59
        self.assertEqual('', out)
2999.1.4 by Ian Clatworthy
more review tweaks including commit of blackbox tests
60
61
    def test_switch_out_of_date_light_checkout(self):
62
        self.make_branch_and_tree('branch')
63
        self.run_bzr('branch branch branch2')
64
        self.build_tree(['branch2/file'])
65
        self.run_bzr('add branch2/file')
66
        self.run_bzr('commit -m add-file branch2')
67
        self.run_bzr('checkout --lightweight branch checkout')
68
        os.chdir('checkout')
69
        out, err = self.run_bzr('switch ../branch2')
70
        #self.assertContainsRe(err, '\+N  file')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
71
        self.assertContainsRe(err, 'Updated to revision 1.\n')
7223.1.1 by Jelmer Vernooij
Display colocated branch name without full path when switching between colocated branches.
72
        self.assertContainsRe(err, 'Switched to branch at .*/branch2.\n')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
73
        self.assertEqual('', out)
3246.5.1 by Robert Collins
* ``bzr switch`` will attempt to find branches to switch to relative to the
74
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
75
    def _test_switch_nick(self, lightweight):
76
        """Check that the nick gets switched too."""
77
        tree1 = self.make_branch_and_tree('branch1')
78
        tree2 = self.make_branch_and_tree('branch2')
79
        tree2.pull(tree1.branch)
7143.15.2 by Jelmer Vernooij
Run autopep8.
80
        checkout = tree1.branch.create_checkout('checkout',
81
                                                lightweight=lightweight)
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
82
        self.assertEqual(checkout.branch.nick, tree1.branch.nick)
83
        self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
7143.15.2 by Jelmer Vernooij
Run autopep8.
84
                         False)
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
85
        self.run_bzr('switch branch2', working_dir='checkout')
86
87
        # we need to get the tree again, otherwise we don't get the new branch
88
        checkout = WorkingTree.open('checkout')
89
        self.assertEqual(checkout.branch.nick, tree2.branch.nick)
90
        self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
7143.15.2 by Jelmer Vernooij
Run autopep8.
91
                         False)
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
92
3565.6.1 by Marius Kruger
Let 'bzr switch' update the nick too.
93
    def test_switch_nick(self):
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
94
        self._test_switch_nick(lightweight=False)
95
96
    def test_switch_nick_lightweight(self):
97
        self._test_switch_nick(lightweight=True)
98
99
    def _test_switch_explicit_nick(self, lightweight):
3565.6.1 by Marius Kruger
Let 'bzr switch' update the nick too.
100
        """Check that the nick gets switched too."""
101
        tree1 = self.make_branch_and_tree('branch1')
102
        tree2 = self.make_branch_and_tree('branch2')
103
        tree2.pull(tree1.branch)
7143.15.2 by Jelmer Vernooij
Run autopep8.
104
        checkout = tree1.branch.create_checkout('checkout',
105
                                                lightweight=lightweight)
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
106
        self.assertEqual(checkout.branch.nick, tree1.branch.nick)
107
        checkout.branch.nick = "explicit_nick"
108
        self.assertEqual(checkout.branch.nick, "explicit_nick")
109
        self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
7143.15.2 by Jelmer Vernooij
Run autopep8.
110
                         "explicit_nick")
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
111
        self.run_bzr('switch branch2', working_dir='checkout')
112
113
        # we need to get the tree again, otherwise we don't get the new branch
114
        checkout = WorkingTree.open('checkout')
115
        self.assertEqual(checkout.branch.nick, tree2.branch.nick)
116
        self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
7143.15.2 by Jelmer Vernooij
Run autopep8.
117
                         tree2.branch.nick)
3565.6.7 by Marius Kruger
* checkouts now use master nick when no explicit nick is set.
118
119
    def test_switch_explicit_nick(self):
120
        self._test_switch_explicit_nick(lightweight=False)
121
122
    def test_switch_explicit_nick_lightweight(self):
123
        self._test_switch_explicit_nick(lightweight=True)
3565.6.1 by Marius Kruger
Let 'bzr switch' update the nick too.
124
3246.5.1 by Robert Collins
* ``bzr switch`` will attempt to find branches to switch to relative to the
125
    def test_switch_finds_relative_branch(self):
3565.6.1 by Marius Kruger
Let 'bzr switch' update the nick too.
126
        """Switch will find 'foo' relative to the branch the checkout is of."""
3246.5.1 by Robert Collins
* ``bzr switch`` will attempt to find branches to switch to relative to the
127
        self.build_tree(['repo/'])
128
        tree1 = self.make_branch_and_tree('repo/brancha')
129
        tree1.commit('foo')
130
        tree2 = self.make_branch_and_tree('repo/branchb')
131
        tree2.pull(tree1.branch)
132
        branchb_id = tree2.commit('bar')
7143.15.2 by Jelmer Vernooij
Run autopep8.
133
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
3246.5.1 by Robert Collins
* ``bzr switch`` will attempt to find branches to switch to relative to the
134
        self.run_bzr(['switch', 'branchb'], working_dir='checkout')
135
        self.assertEqual(branchb_id, checkout.last_revision())
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
136
        checkout = checkout.controldir.open_workingtree()
3246.5.1 by Robert Collins
* ``bzr switch`` will attempt to find branches to switch to relative to the
137
        self.assertEqual(tree2.branch.base, checkout.branch.base)
3602.3.1 by Adrian Wilkins
Test that `bzr switch` finds the sibling of the bound branch of heavy checkout.
138
139
    def test_switch_finds_relative_bound_branch(self):
3602.3.4 by Adrian Wilkins
Improved comments and documentation
140
        """Using switch on a heavy checkout should find master sibling
141
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
142
        The behaviour of lighweight and heavy checkouts should be
5816.6.1 by A. S. Budden
Test harness to stimulate Bug #513709: parent being set incorrectly in switch --create-branch.
143
        consistent when using the convenient "switch to sibling" feature
3602.3.4 by Adrian Wilkins
Improved comments and documentation
144
        Both should switch to a sibling of the branch
145
        they are bound to, and not a sibling of themself"""
146
3602.3.1 by Adrian Wilkins
Test that `bzr switch` finds the sibling of the bound branch of heavy checkout.
147
        self.build_tree(['repo/',
148
                         'heavyco/'])
149
        tree1 = self.make_branch_and_tree('repo/brancha')
150
        tree1.commit('foo')
151
        tree2 = self.make_branch_and_tree('repo/branchb')
152
        tree2.pull(tree1.branch)
153
        branchb_id = tree2.commit('bar')
154
        checkout = tree1.branch.create_checkout('heavyco/a', lightweight=False)
155
        self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a')
6404.6.6 by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer.
156
        # Refresh checkout as 'switch' modified it
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
157
        checkout = checkout.controldir.open_workingtree()
3602.3.1 by Adrian Wilkins
Test that `bzr switch` finds the sibling of the bound branch of heavy checkout.
158
        self.assertEqual(branchb_id, checkout.last_revision())
6404.6.1 by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made.
159
        self.assertEqual(tree2.branch.base,
160
                         checkout.branch.get_bound_location())
4354.2.2 by Aaron Bentley
Enable switch --force for lightweight checkouts after moves.
161
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
162
    def test_switch_finds_relative_unicode_branch(self):
163
        """Switch will find 'foo' relative to the branch the checkout is of."""
5268.8.18 by Jelmer Vernooij
Use UnicodeFilenameFeature.
164
        self.requireFeature(UnicodeFilenameFeature)
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
165
        self.build_tree(['repo/'])
166
        tree1 = self.make_branch_and_tree('repo/brancha')
167
        tree1.commit('foo')
168
        tree2 = self.make_branch_and_tree(u'repo/branch\xe9')
169
        tree2.pull(tree1.branch)
170
        branchb_id = tree2.commit('bar')
7143.15.2 by Jelmer Vernooij
Run autopep8.
171
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
172
        self.run_bzr(['switch', u'branch\xe9'], working_dir='checkout')
173
        self.assertEqual(branchb_id, checkout.last_revision())
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
174
        checkout = checkout.controldir.open_workingtree()
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
175
        self.assertEqual(tree2.branch.base, checkout.branch.base)
176
177
    def test_switch_finds_relative_unicode_branch(self):
178
        """Switch will find 'foo' relative to the branch the checkout is of."""
5268.8.18 by Jelmer Vernooij
Use UnicodeFilenameFeature.
179
        self.requireFeature(UnicodeFilenameFeature)
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
180
        self.build_tree(['repo/'])
181
        tree1 = self.make_branch_and_tree('repo/brancha')
182
        tree1.commit('foo')
183
        tree2 = self.make_branch_and_tree(u'repo/branch\xe9')
184
        tree2.pull(tree1.branch)
185
        branchb_id = tree2.commit('bar')
7143.15.2 by Jelmer Vernooij
Run autopep8.
186
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
187
        self.run_bzr(['switch', u'branch\xe9'], working_dir='checkout')
188
        self.assertEqual(branchb_id, checkout.last_revision())
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
189
        checkout = checkout.controldir.open_workingtree()
5268.8.15 by Jelmer Vernooij
Fix switching to unicode branch names.
190
        self.assertEqual(tree2.branch.base, checkout.branch.base)
191
3984.5.2 by Daniel Watkins
Added blackbox test.
192
    def test_switch_revision(self):
3984.5.14 by Daniel Watkins
Extracted common setup code.
193
        tree = self._create_sample_tree()
3984.5.2 by Daniel Watkins
Added blackbox test.
194
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
195
        self.run_bzr(['switch', 'branch-1', '-r1'], working_dir='checkout')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
196
        self.assertPathExists('checkout/file-1')
197
        self.assertPathDoesNotExist('checkout/file-2')
3984.5.9 by Daniel Watkins
Added test for allowing only revisions to be passed to switch.
198
6437.7.5 by Jelmer Vernooij
"bzr switch -b" in a standalone tree will now create a colocated branch.
199
    def test_switch_into_colocated(self):
200
        # Create a new colocated branch from an existing non-colocated branch.
201
        tree = self.make_branch_and_tree('.', format='development-colo')
202
        self.build_tree(['file-1', 'file-2'])
203
        tree.add('file-1')
204
        revid1 = tree.commit('rev1')
205
        tree.add('file-2')
206
        revid2 = tree.commit('rev2')
207
        self.run_bzr(['switch', '-b', 'anotherbranch'])
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
208
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
209
            {'', 'anotherbranch'},
7490.13.2 by Jelmer Vernooij
Fix reference handling.
210
            set(tree.branch.controldir.branch_names()))
6437.7.5 by Jelmer Vernooij
"bzr switch -b" in a standalone tree will now create a colocated branch.
211
6437.7.6 by Jelmer Vernooij
Add test for --force argument used in standalone branch.
212
    def test_switch_into_unrelated_colocated(self):
213
        # Create a new colocated branch from an existing non-colocated branch.
214
        tree = self.make_branch_and_tree('.', format='development-colo')
215
        self.build_tree(['file-1', 'file-2'])
216
        tree.add('file-1')
217
        revid1 = tree.commit('rev1')
218
        tree.add('file-2')
219
        revid2 = tree.commit('rev2')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
220
        tree.controldir.create_branch(name='foo')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
221
        self.run_bzr_error(['Cannot switch a branch, only a checkout.'],
7143.15.2 by Jelmer Vernooij
Run autopep8.
222
                           'switch foo')
6437.7.6 by Jelmer Vernooij
Add test for --force argument used in standalone branch.
223
        self.run_bzr(['switch', '--force', 'foo'])
224
5268.8.12 by Jelmer Vernooij
support creating new colocated branches from 'bzr switch -b'.
225
    def test_switch_existing_colocated(self):
5268.8.6 by Jelmer Vernooij
More fixes to test.
226
        # Create a branch branch-1 that initially is a checkout of 'foo'
227
        # Use switch to change it to 'anotherbranch'
228
        repo = self.make_repository('branch-1', format='development-colo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
229
        target_branch = repo.controldir.create_branch(name='foo')
230
        repo.controldir.set_branch_reference(target_branch)
231
        tree = repo.controldir.create_workingtree()
5268.8.5 by Jelmer Vernooij
Add tests for switching to colocated branches.
232
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
233
        tree.add('file-1')
234
        revid1 = tree.commit('rev1')
235
        tree.add('file-2')
236
        revid2 = tree.commit('rev2')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
237
        otherbranch = tree.controldir.create_branch(name='anotherbranch')
5268.8.5 by Jelmer Vernooij
Add tests for switching to colocated branches.
238
        otherbranch.generate_revision_history(revid1)
239
        self.run_bzr(['switch', 'anotherbranch'], working_dir='branch-1')
5268.8.10 by Jelmer Vernooij
bzr switch can now switch to colocated branches.
240
        tree = WorkingTree.open("branch-1")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
241
        self.assertEqual(tree.last_revision(), revid1)
242
        self.assertEqual(tree.branch.control_url, otherbranch.control_url)
5268.8.5 by Jelmer Vernooij
Add tests for switching to colocated branches.
243
5268.8.12 by Jelmer Vernooij
support creating new colocated branches from 'bzr switch -b'.
244
    def test_switch_new_colocated(self):
245
        # Create a branch branch-1 that initially is a checkout of 'foo'
246
        # Use switch to create 'anotherbranch' which derives from that
247
        repo = self.make_repository('branch-1', format='development-colo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
248
        target_branch = repo.controldir.create_branch(name='foo')
249
        repo.controldir.set_branch_reference(target_branch)
250
        tree = repo.controldir.create_workingtree()
5268.8.12 by Jelmer Vernooij
support creating new colocated branches from 'bzr switch -b'.
251
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
252
        tree.add('file-1')
253
        revid1 = tree.commit('rev1')
254
        self.run_bzr(['switch', '-b', 'anotherbranch'], working_dir='branch-1')
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
255
        bzrdir = ControlDir.open("branch-1")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
256
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
257
            {b.name for b in bzrdir.list_branches()},
258
            {"foo", "anotherbranch"})
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
259
        self.assertEqual(bzrdir.open_branch().name, "anotherbranch")
260
        self.assertEqual(bzrdir.open_branch().last_revision(), revid1)
5268.8.12 by Jelmer Vernooij
support creating new colocated branches from 'bzr switch -b'.
261
5268.8.17 by Jelmer Vernooij
Support switching to new unicode colocated branch.
262
    def test_switch_new_colocated_unicode(self):
263
        # Create a branch branch-1 that initially is a checkout of 'foo'
264
        # Use switch to create 'branch\xe9' which derives from that
5268.8.18 by Jelmer Vernooij
Use UnicodeFilenameFeature.
265
        self.requireFeature(UnicodeFilenameFeature)
5268.8.17 by Jelmer Vernooij
Support switching to new unicode colocated branch.
266
        repo = self.make_repository('branch-1', format='development-colo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
267
        target_branch = repo.controldir.create_branch(name='foo')
268
        repo.controldir.set_branch_reference(target_branch)
269
        tree = repo.controldir.create_workingtree()
5268.8.17 by Jelmer Vernooij
Support switching to new unicode colocated branch.
270
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
271
        tree.add('file-1')
272
        revid1 = tree.commit('rev1')
273
        self.run_bzr(['switch', '-b', u'branch\xe9'], working_dir='branch-1')
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
274
        bzrdir = ControlDir.open("branch-1")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
275
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
276
            {b.name for b in bzrdir.list_branches()},
277
            {"foo", u"branch\xe9"})
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
278
        self.assertEqual(bzrdir.open_branch().name, u"branch\xe9")
279
        self.assertEqual(bzrdir.open_branch().last_revision(), revid1)
5268.8.17 by Jelmer Vernooij
Support switching to new unicode colocated branch.
280
3984.5.9 by Daniel Watkins
Added test for allowing only revisions to be passed to switch.
281
    def test_switch_only_revision(self):
3984.5.14 by Daniel Watkins
Extracted common setup code.
282
        tree = self._create_sample_tree()
3984.5.9 by Daniel Watkins
Added test for allowing only revisions to be passed to switch.
283
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
284
        self.assertPathExists('checkout/file-1')
285
        self.assertPathExists('checkout/file-2')
3984.5.9 by Daniel Watkins
Added test for allowing only revisions to be passed to switch.
286
        self.run_bzr(['switch', '-r1'], working_dir='checkout')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
287
        self.assertPathExists('checkout/file-1')
288
        self.assertPathDoesNotExist('checkout/file-2')
3984.5.15 by Daniel Watkins
Add to test to ensure that we don't accept a range of revisions.
289
        # Check that we don't accept a range
3984.5.17 by Daniel Watkins
Fixed incorrect call of run_bzr_error.
290
        self.run_bzr_error(
6622.1.29 by Jelmer Vernooij
Fix some more tests.
291
            ['brz switch --revision takes exactly one revision identifier'],
3984.5.17 by Daniel Watkins
Fixed incorrect call of run_bzr_error.
292
            ['switch', '-r0..2'], working_dir='checkout')
3984.5.19 by Andrew Bennetts
Merge lp:bzr, resolving conflicts.
293
4354.2.2 by Aaron Bentley
Enable switch --force for lightweight checkouts after moves.
294
    def prepare_lightweight_switch(self):
295
        branch = self.make_branch('branch')
296
        branch.create_checkout('tree', lightweight=True)
5186.2.2 by Martin Pool
wrap os.rename to insert the source and destination filenames in any exception that may be raised
297
        osutils.rename('branch', 'branch1')
4354.2.2 by Aaron Bentley
Enable switch --force for lightweight checkouts after moves.
298
299
    def test_switch_lightweight_after_branch_moved(self):
300
        self.prepare_lightweight_switch()
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
301
        self.run_bzr('switch --force ../branch1', working_dir='tree')
4354.2.2 by Aaron Bentley
Enable switch --force for lightweight checkouts after moves.
302
        branch_location = WorkingTree.open('tree').branch.base
303
        self.assertEndsWith(branch_location, 'branch1/')
304
305
    def test_switch_lightweight_after_branch_moved_relative(self):
306
        self.prepare_lightweight_switch()
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
307
        self.run_bzr('switch --force branch1',
6538.1.18 by Aaron Bentley
Add --with-changes flag to switch.
308
                     working_dir='tree')
4354.2.2 by Aaron Bentley
Enable switch --force for lightweight checkouts after moves.
309
        branch_location = WorkingTree.open('tree').branch.base
310
        self.assertEndsWith(branch_location, 'branch1/')
4520.1.1 by John Arbash Meinel
'bzr switch -b' can now be used to create the branch while you switch to it.
311
312
    def test_create_branch_no_branch(self):
313
        self.prepare_lightweight_switch()
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
314
        self.run_bzr_error(['cannot create branch without source branch'],
7143.15.2 by Jelmer Vernooij
Run autopep8.
315
                           'switch --create-branch ../branch2', working_dir='tree')
4520.1.1 by John Arbash Meinel
'bzr switch -b' can now be used to create the branch while you switch to it.
316
317
    def test_create_branch(self):
318
        branch = self.make_branch('branch')
319
        tree = branch.create_checkout('tree', lightweight=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
320
        tree.commit('one', rev_id=b'rev-1')
4520.1.1 by John Arbash Meinel
'bzr switch -b' can now be used to create the branch while you switch to it.
321
        self.run_bzr('switch --create-branch ../branch2', working_dir='tree')
322
        tree = WorkingTree.open('tree')
323
        self.assertEndsWith(tree.branch.base, '/branch2/')
324
325
    def test_create_branch_local(self):
326
        branch = self.make_branch('branch')
327
        tree = branch.create_checkout('tree', lightweight=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
328
        tree.commit('one', rev_id=b'rev-1')
4520.1.1 by John Arbash Meinel
'bzr switch -b' can now be used to create the branch while you switch to it.
329
        self.run_bzr('switch --create-branch branch2', working_dir='tree')
330
        tree = WorkingTree.open('tree')
331
        # The new branch should have been created at the same level as
332
        # 'branch', because we did not have a '/' segment
333
        self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)
334
335
    def test_create_branch_short_name(self):
336
        branch = self.make_branch('branch')
337
        tree = branch.create_checkout('tree', lightweight=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
338
        tree.commit('one', rev_id=b'rev-1')
4520.1.1 by John Arbash Meinel
'bzr switch -b' can now be used to create the branch while you switch to it.
339
        self.run_bzr('switch -b branch2', working_dir='tree')
340
        tree = WorkingTree.open('tree')
341
        # The new branch should have been created at the same level as
342
        # 'branch', because we did not have a '/' segment
343
        self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)
4879.2.1 by Neil Martinsen-Burrell
switch should use directory services when creating a branch
344
345
    def test_create_branch_directory_services(self):
346
        branch = self.make_branch('branch')
347
        tree = branch.create_checkout('tree', lightweight=True)
7143.15.2 by Jelmer Vernooij
Run autopep8.
348
4879.2.1 by Neil Martinsen-Burrell
switch should use directory services when creating a branch
349
        class FooLookup(object):
7268.11.2 by Jelmer Vernooij
Add purpose argument.
350
            def look_up(self, name, url, purpose=None):
7143.15.2 by Jelmer Vernooij
Run autopep8.
351
                return 'foo-' + name
4879.2.1 by Neil Martinsen-Burrell
switch should use directory services when creating a branch
352
        directories.register('foo:', FooLookup, 'Create branches named foo-')
4879.2.2 by Neil Martinsen-Burrell
add test cleanup per JAMs review
353
        self.addCleanup(directories.remove, 'foo:')
4879.2.1 by Neil Martinsen-Burrell
switch should use directory services when creating a branch
354
        self.run_bzr('switch -b foo:branch2', working_dir='tree')
355
        tree = WorkingTree.open('tree')
356
        self.assertEndsWith(tree.branch.base, 'foo-branch2/')
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
357
358
    def test_switch_with_post_switch_hook(self):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
359
        from breezy import branch as _mod_branch
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
360
        calls = []
361
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
7143.15.2 by Jelmer Vernooij
Run autopep8.
362
                                                    calls.append, None)
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
363
        self.make_branch_and_tree('branch')
364
        self.run_bzr('branch branch branch2')
365
        self.run_bzr('checkout branch checkout')
366
        os.chdir('checkout')
367
        self.assertLength(0, calls)
368
        out, err = self.run_bzr('switch ../branch2')
369
        self.assertLength(1, calls)
370
371
    def test_switch_lightweight_co_with_post_switch_hook(self):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
372
        from breezy import branch as _mod_branch
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
373
        calls = []
374
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
7143.15.2 by Jelmer Vernooij
Run autopep8.
375
                                                    calls.append, None)
5107.3.6 by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts.
376
        self.make_branch_and_tree('branch')
377
        self.run_bzr('branch branch branch2')
378
        self.run_bzr('checkout --lightweight branch checkout')
379
        os.chdir('checkout')
380
        self.assertLength(0, calls)
381
        out, err = self.run_bzr('switch ../branch2')
382
        self.assertLength(1, calls)
5171.3.13 by Martin von Gagern
Add --directory option to 7 more commands.
383
384
    def test_switch_lightweight_directory(self):
385
        """Test --directory option"""
386
387
        # create a source branch
388
        a_tree = self.make_branch_and_tree('a')
6855.4.1 by Jelmer Vernooij
Yet more bees.
389
        self.build_tree_contents([('a/a', b'initial\n')])
5171.3.13 by Martin von Gagern
Add --directory option to 7 more commands.
390
        a_tree.add('a')
391
        a_tree.commit(message='initial')
392
393
        # clone and add a differing revision
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
394
        b_tree = a_tree.controldir.sprout('b').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
395
        self.build_tree_contents([('b/a', b'initial\nmore\n')])
5171.3.13 by Martin von Gagern
Add --directory option to 7 more commands.
396
        b_tree.commit(message='more')
397
398
        self.run_bzr('checkout --lightweight a checkout')
399
        self.run_bzr('switch --directory checkout b')
7029.4.2 by Jelmer Vernooij
Fix more merge tests.
400
        self.assertFileEqual(b'initial\nmore\n', 'checkout/a')
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.
401
6015.7.2 by John Arbash Meinel
Bug #812285. Add an effort test to show that things have improved.
402
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
403
class TestSwitchParentLocationBase(TestCaseWithTransport):
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.
404
405
    def setUp(self):
406
        """Set up a repository and branch ready for testing."""
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
407
        super(TestSwitchParentLocationBase, self).setUp()
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.
408
        self.script_runner = script.ScriptRunner()
409
        self.script_runner.run_script(self, '''
7385.2.1 by Jelmer Vernooij
Rename init-repo to init-shared-repo.
410
                $ brz init-shared-repo --no-trees repo
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.
411
                Shared repository...
412
                Location:
413
                  shared repository: repo
6622.1.29 by Jelmer Vernooij
Fix some more tests.
414
                $ brz init repo/trunk
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.
415
                Created a repository branch...
416
                Using shared repository: ...
417
                ''')
418
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
419
    def assertParent(self, expected_parent, branch):
5816.6.11 by A. S. Budden
Refactored assertParentCorrect to check the full path.
420
        """Verify that the parent is not None and is set correctly."""
421
        actual_parent = branch.get_parent()
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
422
        self.assertIsSameRealPath(urlutils.local_path_to_url(expected_parent),
423
                                  branch.get_parent())
424
425
426
class TestSwitchParentLocation(TestSwitchParentLocationBase):
427
428
    def _checkout_and_switch(self, option=''):
5816.6.8 by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight.
429
        self.script_runner.run_script(self, '''
6622.1.29 by Jelmer Vernooij
Fix some more tests.
430
                $ brz checkout %(option)s repo/trunk checkout
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
431
                $ cd checkout
6622.1.29 by Jelmer Vernooij
Fix some more tests.
432
                $ brz switch --create-branch switched
5816.6.8 by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight.
433
                2>Tree is up to date at revision 0.
7223.1.1 by Jelmer Vernooij
Display colocated branch name without full path when switching between colocated branches.
434
                2>Switched to branch at .../switched/
5816.6.11 by A. S. Budden
Refactored assertParentCorrect to check the full path.
435
                $ cd ..
5816.6.9 by A. S. Budden
Use locals() instead of kwargs so that parameters are more explicit.
436
                ''' % locals())
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
437
        bound_branch = branch.Branch.open_containing('checkout')[0]
438
        master_branch = branch.Branch.open_containing('repo/switched')[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.
439
        return (bound_branch, master_branch)
5816.6.8 by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight.
440
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.
441
    def test_switch_parent_lightweight(self):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
442
        """Lightweight checkout using brz switch."""
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
443
        bb, mb = self._checkout_and_switch(option='--lightweight')
444
        self.assertParent('repo/trunk', bb)
445
        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.
446
447
    def test_switch_parent_heavyweight(self):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
448
        """Heavyweight checkout using brz switch."""
5816.7.1 by Vincent Ladeuil
Remove duplication and simplify.
449
        bb, mb = self._checkout_and_switch()
450
        self.assertParent('repo/trunk', bb)
451
        self.assertParent('repo/trunk', mb)
5816.6.11 by A. S. Budden
Refactored assertParentCorrect to check the full path.
452
6015.7.2 by John Arbash Meinel
Bug #812285. Add an effort test to show that things have improved.
453
454
class TestSwitchDoesntOpenMasterBranch(TestCaseWithTransport):
455
    # See https://bugs.launchpad.net/bzr/+bug/812285
6622.1.29 by Jelmer Vernooij
Fix some more tests.
456
    # "brz switch --create-branch" can point the new branch's parent to the
6015.7.2 by John Arbash Meinel
Bug #812285. Add an effort test to show that things have improved.
457
    # master branch, but it doesn't have to open it to do so.
458
459
    def test_switch_create_doesnt_open_master_branch(self):
460
        master = self.make_branch_and_tree('master')
461
        master.commit('one')
462
        # Note: not a lightweight checkout
463
        checkout = master.branch.create_checkout('checkout')
464
        opened = []
7143.15.2 by Jelmer Vernooij
Run autopep8.
465
6015.7.2 by John Arbash Meinel
Bug #812285. Add an effort test to show that things have improved.
466
        def open_hook(branch):
467
            # Just append the final directory of the branch
468
            name = branch.base.rstrip('/').rsplit('/', 1)[1]
469
            opened.append(name)
470
        branch.Branch.hooks.install_named_hook('open', open_hook,
471
                                               'open_hook_logger')
472
        self.run_bzr('switch --create-branch -d checkout feature')
473
        # We only open the master branch 1 time.
474
        # This test should be cleaner to write, but see bug:
475
        #  https://bugs.launchpad.net/bzr/+bug/812295
476
        self.assertEqual(1, opened.count('master'))
6366.1.5 by Jelmer Vernooij
add test for hpss call / connection count of 'bzr switch'.
477
478
479
class TestSmartServerSwitch(TestCaseWithTransport):
480
481
    def test_switch_lightweight(self):
482
        self.setup_smart_server_with_call_log()
483
        t = self.make_branch_and_tree('from')
484
        for count in range(9):
485
            t.commit(message='commit %d' % count)
486
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
7143.15.2 by Jelmer Vernooij
Run autopep8.
487
                                 'target'])
6366.1.5 by Jelmer Vernooij
add test for hpss call / connection count of 'bzr switch'.
488
        self.reset_smart_call_log()
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
489
        self.run_bzr(['switch', self.get_url('from')], working_dir='target')
6366.1.5 by Jelmer Vernooij
add test for hpss call / connection count of 'bzr switch'.
490
        # This figure represent the amount of work to perform this use case. It
491
        # is entirely ok to reduce this number if a test fails due to rpc_count
492
        # being too low. If rpc_count increases, more network roundtrips have
493
        # become necessary for this use case. Please do not adjust this number
494
        # upwards without agreement from bzr's network support maintainers.
7143.18.1 by Jelmer Vernooij
Fix 'bzr switch' in git repositories.
495
        self.assertLength(21, self.hpss_calls)
496
        self.assertLength(3, self.hpss_connections)
6366.1.5 by Jelmer Vernooij
add test for hpss call / connection count of 'bzr switch'.
497
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
6538.1.17 by Aaron Bentley
Switch command stores/restores uncommitted changes.
498
499
500
class TestSwitchUncommitted(TestCaseWithTransport):
501
6538.1.18 by Aaron Bentley
Add --with-changes flag to switch.
502
    def prepare(self):
6538.1.17 by Aaron Bentley
Switch command stores/restores uncommitted changes.
503
        tree = self.make_branch_and_tree('orig')
504
        tree.commit('')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
505
        tree.branch.controldir.sprout('new')
6538.1.17 by Aaron Bentley
Switch command stores/restores uncommitted changes.
506
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
507
        self.build_tree(['checkout/a'])
508
        self.assertPathExists('checkout/a')
509
        checkout.add('a')
6538.1.34 by Aaron Bentley
Update blackbox test to show storing and restoring in one switch.
510
        return checkout
6538.1.18 by Aaron Bentley
Add --with-changes flag to switch.
511
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
512
    def test_store_and_restore_uncommitted(self):
6538.1.34 by Aaron Bentley
Update blackbox test to show storing and restoring in one switch.
513
        checkout = self.prepare()
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
514
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'new'])
6538.1.34 by Aaron Bentley
Update blackbox test to show storing and restoring in one switch.
515
        self.build_tree(['checkout/b'])
516
        checkout.add('b')
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
517
        self.assertPathDoesNotExist('checkout/a')
6538.1.34 by Aaron Bentley
Update blackbox test to show storing and restoring in one switch.
518
        self.assertPathExists('checkout/b')
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
519
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'orig'])
520
        self.assertPathExists('checkout/a')
6538.1.34 by Aaron Bentley
Update blackbox test to show storing and restoring in one switch.
521
        self.assertPathDoesNotExist('checkout/b')
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
522
523
    def test_does_not_store(self):
6538.1.18 by Aaron Bentley
Add --with-changes flag to switch.
524
        self.prepare()
6538.1.17 by Aaron Bentley
Switch command stores/restores uncommitted changes.
525
        self.run_bzr(['switch', '-d', 'checkout', 'new'])
6538.1.30 by Aaron Bentley
Make *not* storing on switch the default.
526
        self.assertPathExists('checkout/a')
527
528
    def test_does_not_restore_changes(self):
529
        self.prepare()
530
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'new'])
6538.1.17 by Aaron Bentley
Switch command stores/restores uncommitted changes.
531
        self.assertPathDoesNotExist('checkout/a')
532
        self.run_bzr(['switch', '-d', 'checkout', 'orig'])
6538.1.18 by Aaron Bentley
Add --with-changes flag to switch.
533
        self.assertPathDoesNotExist('checkout/a')
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
534
6929.8.1 by Jelmer Vernooij
merge tests.
535
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
536
class TestSwitchStandAloneCorruption(TestCaseWithTransport):
6929.8.1 by Jelmer Vernooij
merge tests.
537
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
538
    def test_empty_tree_switch(self):
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
539
        """switch . on an empty tree gets infinite recursion
540
541
        Inspired by: https://bugs.launchpad.net/bzr/+bug/1018628
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
542
        """
543
        self.script_runner = script.ScriptRunner()
544
        self.script_runner.run_script(self, '''
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
545
            $ brz init
546
            Created a standalone tree (format: 2a)
547
            $ brz switch .
548
            2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.
549
            ''')
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
550
551
    def test_switch_on_previous_rev(self):
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
552
        """switch to previous rev in a standalone directory
553
554
        Inspired by: https://bugs.launchpad.net/brz/+bug/1018628
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
555
        """
556
        self.script_runner = script.ScriptRunner()
557
        self.script_runner.run_script(self, '''
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
558
           $ brz init
559
           Created a standalone tree (format: 2a)
560
           $ brz commit -m 1 --unchanged
561
           $ brz commit -m 2 --unchanged
562
           $ brz switch -r 1
563
           2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.''',
7143.15.2 by Jelmer Vernooij
Run autopep8.
564
                                      null_output_matches_anything=True)
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
565
6573.2.2 by Spundun Bhatt
Even a simple switch test locks the colo repo.
566
    def test_switch_create_colo_locks_repo_path(self):
6573.2.1 by Spundun Bhatt
Added blackbox unittests for bug https://bugs.launchpad.net/bzr/+bug/1018628
567
        self.script_runner = script.ScriptRunner()
568
        self.script_runner.run_script(self, '''
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
569
            $ mkdir mywork
570
            $ cd mywork
571
            $ brz init
572
            Created a standalone tree (format: 2a)
573
            $ echo A > a && brz add a && brz commit -m A
574
            $ brz switch -b br1
575
            $ cd ..
576
            $ mv mywork mywork1
577
            $ cd mywork1
578
            $ brz branches
7236.1.3 by Jelmer Vernooij
Fix test, simplify logic.
579
              br1
6929.8.2 by Jelmer Vernooij
Fix new switch tests.
580
            ''', null_output_matches_anything=True)
7143.4.1 by Jelmer Vernooij
Fix behaviour when specifying a revision to 'bzr switch -b blah'.
581
582
    def test_switch_to_new_branch_on_old_rev(self):
583
        """switch to previous rev in a standalone directory
584
585
        Inspired by: https://bugs.launchpad.net/brz/+bug/933362
586
        """
587
        self.script_runner = script.ScriptRunner()
588
        self.script_runner.run_script(self, '''
589
           $ brz init
590
           Created a standalone tree (format: 2a)
591
           $ brz switch -b trunk
592
           2>Tree is up to date at revision 0.
7223.1.1 by Jelmer Vernooij
Display colocated branch name without full path when switching between colocated branches.
593
           2>Switched to branch trunk
7143.4.1 by Jelmer Vernooij
Fix behaviour when specifying a revision to 'bzr switch -b blah'.
594
           $ brz commit -m 1 --unchanged
595
           2>Committing to: ...
596
           2>Committed revision 1.
597
           $ brz commit -m 2 --unchanged
598
           2>Committing to: ...
599
           2>Committed revision 2.
600
           $ brz switch -b blah -r1
601
           2>Updated to revision 1.
7223.1.1 by Jelmer Vernooij
Display colocated branch name without full path when switching between colocated branches.
602
           2>Switched to branch blah
7143.4.1 by Jelmer Vernooij
Fix behaviour when specifying a revision to 'bzr switch -b blah'.
603
           $ brz branches
604
           * blah
605
             trunk
606
           $ brz st
607
           ''')