~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_switch.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-27 05:35:00 UTC
  • mfrom: (4570 +trunk)
  • mto: (4634.6.29 2.0)
  • mto: This revision was merged to the branch mainline in revision 4680.
  • Revision ID: andrew.bennetts@canonical.com-20090727053500-q76zsn2dx33jhmj5
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
 
19
19
"""Tests for the switch command of bzr."""
133
133
        self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a')
134
134
        self.assertEqual(branchb_id, checkout.last_revision())
135
135
        self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location())
 
136
 
 
137
    def prepare_lightweight_switch(self):
 
138
        branch = self.make_branch('branch')
 
139
        branch.create_checkout('tree', lightweight=True)
 
140
        os.rename('branch', 'branch1')
 
141
 
 
142
    def test_switch_lightweight_after_branch_moved(self):
 
143
        self.prepare_lightweight_switch()
 
144
        self.run_bzr('switch --force ../branch1', working_dir='tree')
 
145
        branch_location = WorkingTree.open('tree').branch.base
 
146
        self.assertEndsWith(branch_location, 'branch1/')
 
147
 
 
148
    def test_switch_lightweight_after_branch_moved_relative(self):
 
149
        self.prepare_lightweight_switch()
 
150
        self.run_bzr('switch --force branch1', working_dir='tree')
 
151
        branch_location = WorkingTree.open('tree').branch.base
 
152
        self.assertEndsWith(branch_location, 'branch1/')
 
153
 
 
154
    def test_create_branch_no_branch(self):
 
155
        self.prepare_lightweight_switch()
 
156
        self.run_bzr_error(['cannot create branch without source branch'],
 
157
            'switch --create-branch ../branch2', working_dir='tree')
 
158
 
 
159
    def test_create_branch(self):
 
160
        branch = self.make_branch('branch')
 
161
        tree = branch.create_checkout('tree', lightweight=True)
 
162
        tree.commit('one', rev_id='rev-1')
 
163
        self.run_bzr('switch --create-branch ../branch2', working_dir='tree')
 
164
        tree = WorkingTree.open('tree')
 
165
        self.assertEndsWith(tree.branch.base, '/branch2/')
 
166
 
 
167
    def test_create_branch_local(self):
 
168
        branch = self.make_branch('branch')
 
169
        tree = branch.create_checkout('tree', lightweight=True)
 
170
        tree.commit('one', rev_id='rev-1')
 
171
        self.run_bzr('switch --create-branch branch2', working_dir='tree')
 
172
        tree = WorkingTree.open('tree')
 
173
        # The new branch should have been created at the same level as
 
174
        # 'branch', because we did not have a '/' segment
 
175
        self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)
 
176
 
 
177
    def test_create_branch_short_name(self):
 
178
        branch = self.make_branch('branch')
 
179
        tree = branch.create_checkout('tree', lightweight=True)
 
180
        tree.commit('one', rev_id='rev-1')
 
181
        self.run_bzr('switch -b branch2', working_dir='tree')
 
182
        tree = WorkingTree.open('tree')
 
183
        # The new branch should have been created at the same level as
 
184
        # 'branch', because we did not have a '/' segment
 
185
        self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)