~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/lock_helpers.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-03 07:18:36 UTC
  • mto: (5008.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5009.
  • Revision ID: v.ladeuil+lp@free.fr-20100203071836-u9b86q68fr9ri5s6
Fix NEWS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Helper functions/classes for testing locking"""
18
18
 
19
19
from bzrlib import errors
 
20
from bzrlib.decorators import only_raises
20
21
 
21
22
 
22
23
class TestPreventLocking(errors.LockError):
44
45
        self.__dict__['_allow_read'] = True
45
46
        self.__dict__['_allow_unlock'] = True
46
47
 
 
48
    def __eq__(self, other):
 
49
        # Branch objects look for controlfiles == repo.controlfiles.
 
50
        if type(other) is LockWrapper:
 
51
            return self._other == other._other
 
52
        return False
 
53
 
47
54
    def __getattr__(self, attr):
48
55
        return getattr(self._other, attr)
49
56
 
56
63
            return self._other.lock_read()
57
64
        raise TestPreventLocking('lock_read disabled')
58
65
 
59
 
    def lock_write(self):
 
66
    def lock_write(self, token=None):
60
67
        self._sequence.append((self._other_id, 'lw', self._allow_write))
61
68
        if self._allow_write:
62
69
            return self._other.lock_write()
63
70
        raise TestPreventLocking('lock_write disabled')
64
71
 
 
72
    @only_raises(errors.LockNotHeld, errors.LockBroken)
65
73
    def unlock(self):
66
74
        self._sequence.append((self._other_id, 'ul', self._allow_unlock))
67
75
        if self._allow_unlock: