~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2010-05-10 11:34:20 UTC
  • mfrom: (5218 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5221.
  • Revision ID: aaron@aaronbentley.com-20100510113420-toh2d5yioobb5uq1
Merged bzr.dev into transform-commit-full.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import os
22
22
 
 
23
from bzrlib import osutils
23
24
from bzrlib.workingtree import WorkingTree
24
25
from bzrlib.tests.blackbox import ExternalBase
25
26
from bzrlib.directory_service import directories
167
168
    def prepare_lightweight_switch(self):
168
169
        branch = self.make_branch('branch')
169
170
        branch.create_checkout('tree', lightweight=True)
170
 
        os.rename('branch', 'branch1')
 
171
        osutils.rename('branch', 'branch1')
171
172
 
172
173
    def test_switch_lightweight_after_branch_moved(self):
173
174
        self.prepare_lightweight_switch()
225
226
        self.run_bzr('switch -b foo:branch2', working_dir='tree')
226
227
        tree = WorkingTree.open('tree')
227
228
        self.assertEndsWith(tree.branch.base, 'foo-branch2/')
 
229
 
 
230
    def test_switch_with_post_switch_hook(self):
 
231
        from bzrlib import branch as _mod_branch
 
232
        calls = []
 
233
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
 
234
            calls.append, None)
 
235
        self.make_branch_and_tree('branch')
 
236
        self.run_bzr('branch branch branch2')
 
237
        self.run_bzr('checkout branch checkout')
 
238
        os.chdir('checkout')
 
239
        self.assertLength(0, calls)
 
240
        out, err = self.run_bzr('switch ../branch2')
 
241
        self.assertLength(1, calls)
 
242
 
 
243
    def test_switch_lightweight_co_with_post_switch_hook(self):
 
244
        from bzrlib import branch as _mod_branch
 
245
        calls = []
 
246
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
 
247
            calls.append, None)
 
248
        self.make_branch_and_tree('branch')
 
249
        self.run_bzr('branch branch branch2')
 
250
        self.run_bzr('checkout --lightweight branch checkout')
 
251
        os.chdir('checkout')
 
252
        self.assertLength(0, calls)
 
253
        out, err = self.run_bzr('switch ../branch2')
 
254
        self.assertLength(1, calls)