~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-20 13:34:07 UTC
  • mto: (5622.4.1 uninstall-hook)
  • mto: This revision was merged to the branch mainline in revision 5747.
  • Revision ID: jelmer@samba.org-20110220133407-zhgrvuhhc1e3j2fn
Add more lazily usable hook points.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    osutils,
46
46
    trace,
47
47
    )
48
 
from bzrlib.hooks import HookPoint, Hooks
 
48
from bzrlib.hooks import Hooks
49
49
 
50
50
 
51
51
class LockHooks(Hooks):
52
52
 
53
 
    def __init__(self):
54
 
        Hooks.__init__(self)
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))
 
53
    def __init__(self, module_name, member_name):
 
54
        Hooks.__init__(self, module_name, member_name)
 
55
        self.add_hook('lock_acquired',
 
56
            "Called with a bzrlib.lock.LockResult when a physical lock is "
 
57
            "acquired.", (1, 8))
 
58
        self.add_hook('lock_released',
 
59
            "Called with a bzrlib.lock.LockResult when a physical lock is "
 
60
            "released.", (1, 8))
 
61
        self.add_hook('lock_broken',
 
62
            "Called with a bzrlib.lock.LockResult when a physical lock is "
 
63
            "broken.", (1, 15))
64
64
 
65
65
 
66
66
class Lock(object):
69
69
    :cvar hooks: Hook dictionary for operations on locks.
70
70
    """
71
71
 
72
 
    hooks = LockHooks()
 
72
    hooks = LockHooks("bzrlib.lock", "Lock.hooks")
73
73
 
74
74
 
75
75
class LockResult(object):