48
from bzrlib.hooks import Hooks
49
from bzrlib.i18n import gettext
48
from bzrlib.hooks import HookPoint, Hooks
51
51
class LockHooks(Hooks):
53
53
def __init__(self):
54
Hooks.__init__(self, "bzrlib.lock", "Lock.hooks")
55
self.add_hook('lock_acquired',
56
"Called with a bzrlib.lock.LockResult when a physical lock is "
58
self.add_hook('lock_released',
59
"Called with a bzrlib.lock.LockResult when a physical lock is "
61
self.add_hook('lock_broken',
62
"Called with a bzrlib.lock.LockResult when a physical lock is "
55
self.create_hook(HookPoint('lock_acquired',
56
"Called with a bzrlib.lock.LockResult when a physical lock is "
57
"acquired.", (1, 8), None))
58
self.create_hook(HookPoint('lock_released',
59
"Called with a bzrlib.lock.LockResult when a physical lock is "
60
"released.", (1, 8), None))
61
self.create_hook(HookPoint('lock_broken',
62
"Called with a bzrlib.lock.LockResult when a physical lock is "
63
"broken.", (1, 15), None))
66
66
class Lock(object):
544
550
type_name = 'read'
546
552
type_name = 'write'
547
trace.note(gettext('{0!r} was {1} locked again'), self, type_name)
553
trace.note('%r was %s locked again', self, type_name)
548
554
self._prev_lock = lock_type