~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-05-04 13:55:32 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504135532-f0152b27530fd30c
Hook in the full break-lock ui.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import os
20
20
 
 
21
import bzrlib
 
22
import bzrlib.errors as errors
21
23
from bzrlib.branch import Branch
22
24
from bzrlib.bzrdir import BzrDir
23
25
from bzrlib.tests.blackbox import ExternalBase
48
50
             'repo/branch/',
49
51
             'checkout/'])
50
52
        bzrlib.bzrdir.BzrDir.create('master-repo').create_repository()
51
 
        self.master_branch = bzrlib.bzrdir.create_branch_convenience(
 
53
        self.master_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(
52
54
            'master-repo/master-branch')
53
55
        bzrlib.bzrdir.BzrDir.create('repo').create_repository()
54
 
        bzrlib.bzrdir.create_branch_convenience('repo/branch')
55
 
        local_branch = bzrlib.bzrdir.create_branch_convenience('repo/branch')
 
56
        local_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('repo/branch')
56
57
        local_branch.bind(self.master_branch)
57
58
        checkoutdir = bzrlib.bzrdir.BzrDir.create('checkout')
58
59
        bzrlib.branch.BranchReferenceFormat().initialize(
59
60
            checkoutdir, local_branch)
60
 
        self.wt = bzrlib.workingtree.WorkingTree.open('checkout')
 
61
        self.wt = checkoutdir.create_workingtree()
61
62
 
62
63
    def test_break_lock_help(self):
63
64
        out, err = self.run_bzr('break-lock', '--help')
67
68
    def test_break_lock_everything_locked(self):
68
69
        ### if everything is locked, we should be able to unlock the lot.
69
70
        # sketch of test:
70
 
        # setup a ui factory with precanned answers to the 'should I break lock
71
 
        # tests' 
72
 
        ### bzrlib.ui.ui_factory = ...
73
71
        # lock the lot:
74
72
        self.wt.lock_write()
75
73
        self.master_branch.lock_write()
76
74
        # run the break-lock
77
 
        self.run_bzr('break-lock', 'checkout')
78
 
        # restore (in a finally) the ui
79
 
        bzrlib.ui.ui_factory = originalfactory
 
75
        # we need 5 yes's - wt, branch, repo, bound branch, bound repo.
 
76
        self.run_bzr('break-lock', 'checkout', stdin="y\ny\ny\ny\ny\n")
 
77
        # a new tree instance should be lockable
 
78
        wt = bzrlib.workingtree.WorkingTree.open('checkout')
 
79
        wt.lock_write()
 
80
        wt.unlock()
 
81
        # and a new instance of the master branch 
 
82
        mb = wt.branch.get_master_branch()
 
83
        mb.lock_write()
 
84
        mb.unlock()
 
85
        self.assertRaises(errors.LockBroken, self.wt.unlock)
 
86
        self.assertRaises(errors.LockBroken, self.master_branch.unlock)