~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev into cleanup resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib
22
22
from bzrlib import (
 
23
    branch,
 
24
    bzrdir,
23
25
    errors,
24
26
    lockdir,
 
27
    tests,
25
28
    )
26
 
from bzrlib.branch import Branch
27
 
from bzrlib.bzrdir import BzrDir
28
 
from bzrlib.tests.blackbox import ExternalBase
29
 
 
30
 
 
31
 
class TestBreakLock(ExternalBase):
 
29
 
 
30
 
 
31
class TestBreakLock(tests.TestCaseWithTransport):
32
32
 
33
33
    # General principal for break-lock: All the elements that might be locked
34
34
    # by a bzr operation on PATH, are candidates that break-lock may unlock.
52
52
             'repo/',
53
53
             'repo/branch/',
54
54
             'checkout/'])
55
 
        bzrlib.bzrdir.BzrDir.create('master-repo').create_repository()
56
 
        self.master_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(
 
55
        bzrdir.BzrDir.create('master-repo').create_repository()
 
56
        self.master_branch = bzrdir.BzrDir.create_branch_convenience(
57
57
            'master-repo/master-branch')
58
 
        bzrlib.bzrdir.BzrDir.create('repo').create_repository()
59
 
        local_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('repo/branch')
 
58
        bzrdir.BzrDir.create('repo').create_repository()
 
59
        local_branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
60
60
        local_branch.bind(self.master_branch)
61
 
        checkoutdir = bzrlib.bzrdir.BzrDir.create('checkout')
62
 
        bzrlib.branch.BranchReferenceFormat().initialize(
 
61
        checkoutdir = bzrdir.BzrDir.create('checkout')
 
62
        branch.BranchReferenceFormat().initialize(
63
63
            checkoutdir, target_branch=local_branch)
64
64
        self.wt = checkoutdir.create_workingtree()
65
65
 
82
82
        # we need 5 yes's - wt, branch, repo, bound branch, bound repo.
83
83
        self.run_bzr('break-lock checkout', stdin="y\ny\ny\ny\n")
84
84
        # a new tree instance should be lockable
85
 
        branch = bzrlib.branch.Branch.open('checkout')
86
 
        branch.lock_write()
87
 
        branch.unlock()
 
85
        br = branch.Branch.open('checkout')
 
86
        br.lock_write()
 
87
        br.unlock()
88
88
        # and a new instance of the master branch
89
 
        mb = branch.get_master_branch()
 
89
        mb = br.get_master_branch()
90
90
        mb.lock_write()
91
91
        mb.unlock()
92
92
        self.assertRaises(errors.LockBroken, self.wt.unlock)
93
93
        self.assertRaises(errors.LockBroken, self.master_branch.unlock)
94
94
 
95
95
 
96
 
class TestBreakLockOldBranch(ExternalBase):
 
96
class TestBreakLockOldBranch(tests.TestCaseWithTransport):
97
97
 
98
98
    def test_break_lock_format_5_bzrdir(self):
99
99
        # break lock on a format 5 bzrdir should just return
100
 
        self.make_branch_and_tree('foo', format=bzrlib.bzrdir.BzrDirFormat5())
 
100
        self.make_branch_and_tree('foo', format=bzrdir.BzrDirFormat5())
101
101
        out, err = self.run_bzr('break-lock foo')
102
102
        self.assertEqual('', out)
103
103
        self.assertEqual('', err)