~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 15:02:51 UTC
  • mfrom: (6437.3.19 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120123150251-skmauxb1q7h6w31t
Merge 2.5 branch.

Show diffs side-by-side

added added

removed removed

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