~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-02-14 17:22:37 UTC
  • mfrom: (6466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120214172237-7dv7er3n4uy8d5m4
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
        self.assertPathExists('checkout/file-1')
182
182
        self.assertPathDoesNotExist('checkout/file-2')
183
183
 
 
184
    def test_switch_into_colocated(self):
 
185
        # Create a new colocated branch from an existing non-colocated branch.
 
186
        tree = self.make_branch_and_tree('.', format='development-colo')
 
187
        self.build_tree(['file-1', 'file-2'])
 
188
        tree.add('file-1')
 
189
        revid1 = tree.commit('rev1')
 
190
        tree.add('file-2')
 
191
        revid2 = tree.commit('rev2')
 
192
        self.run_bzr(['switch', '-b', 'anotherbranch'])
 
193
        self.assertEquals(
 
194
            ['', 'anotherbranch'],
 
195
            tree.branch.bzrdir.get_branches().keys())
 
196
 
 
197
    def test_switch_into_unrelated_colocated(self):
 
198
        # Create a new colocated branch from an existing non-colocated branch.
 
199
        tree = self.make_branch_and_tree('.', format='development-colo')
 
200
        self.build_tree(['file-1', 'file-2'])
 
201
        tree.add('file-1')
 
202
        revid1 = tree.commit('rev1')
 
203
        tree.add('file-2')
 
204
        revid2 = tree.commit('rev2')
 
205
        tree.bzrdir.create_branch(name='foo')
 
206
        self.run_bzr_error(['Cannot switch a branch, only a checkout.'],
 
207
            'switch foo')
 
208
        self.run_bzr(['switch', '--force', 'foo'])
 
209
 
184
210
    def test_switch_existing_colocated(self):
185
211
        # Create a branch branch-1 that initially is a checkout of 'foo'
186
212
        # Use switch to change it to 'anotherbranch'
187
213
        repo = self.make_repository('branch-1', format='development-colo')
188
214
        target_branch = repo.bzrdir.create_branch(name='foo')
189
 
        branch.BranchReferenceFormat().initialize(
190
 
            repo.bzrdir, target_branch=target_branch)
 
215
        repo.bzrdir.set_branch_reference(target_branch)
191
216
        tree = repo.bzrdir.create_workingtree()
192
217
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
193
218
        tree.add('file-1')
206
231
        # Use switch to create 'anotherbranch' which derives from that
207
232
        repo = self.make_repository('branch-1', format='development-colo')
208
233
        target_branch = repo.bzrdir.create_branch(name='foo')
209
 
        branch.BranchReferenceFormat().initialize(
210
 
            repo.bzrdir, target_branch=target_branch)
 
234
        repo.bzrdir.set_branch_reference(target_branch)
211
235
        tree = repo.bzrdir.create_workingtree()
212
236
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
213
237
        tree.add('file-1')
226
250
        self.requireFeature(UnicodeFilenameFeature)
227
251
        repo = self.make_repository('branch-1', format='development-colo')
228
252
        target_branch = repo.bzrdir.create_branch(name='foo')
229
 
        branch.BranchReferenceFormat().initialize(
230
 
            repo.bzrdir, target_branch=target_branch)
 
253
        repo.bzrdir.set_branch_reference(target_branch)
231
254
        tree = repo.bzrdir.create_workingtree()
232
255
        self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
233
256
        tree.add('file-1')