~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_locking.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    lockdir,
25
25
    )
26
26
from bzrlib.tests import TestSkipped
 
27
from bzrlib.tests.matchers import *
27
28
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
28
29
 
29
30
 
44
45
        self.assertFalse(wt.is_locked())
45
46
        self.assertFalse(wt.branch.is_locked())
46
47
 
 
48
    def test_lock_read_returns_unlocker(self):
 
49
        wt = self.make_branch_and_tree('.')
 
50
        self.assertThat(wt.lock_read, ReturnsUnlockable(wt))
 
51
 
47
52
    def test_trivial_lock_write_unlock(self):
48
53
        """Locking for write and unlocking should work trivially."""
49
54
        wt = self.make_branch_and_tree('.')
59
64
        self.assertFalse(wt.is_locked())
60
65
        self.assertFalse(wt.branch.is_locked())
61
66
 
 
67
    def test_lock_write_returns_unlocker(self):
 
68
        wt = self.make_branch_and_tree('.')
 
69
        self.assertThat(wt.lock_write, ReturnsUnlockable(wt))
 
70
 
62
71
    def test_trivial_lock_tree_write_unlock(self):
63
72
        """Locking for tree write is ok when the branch is not locked."""
64
73
        wt = self.make_branch_and_tree('.')
74
83
        self.assertFalse(wt.is_locked())
75
84
        self.assertFalse(wt.branch.is_locked())
76
85
 
 
86
    def test_lock_tree_write_returns_unlocker(self):
 
87
        wt = self.make_branch_and_tree('.')
 
88
        self.assertThat(wt.lock_tree_write, ReturnsUnlockable(wt))
 
89
 
77
90
    def test_trivial_lock_tree_write_branch_read_locked(self):
78
91
        """It is ok to lock_tree_write when the branch is read locked."""
79
92
        wt = self.make_branch_and_tree('.')