~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2009-03-18 03:47:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4162.
  • Revision ID: robertc@robertcollins.net-20090318034730-xex5ks3t5ct7gin6
Add a BzrDir.pre_open hook for use by the smart server gaol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    )
76
76
 
77
77
from bzrlib import (
 
78
    hooks,
78
79
    registry,
79
80
    symbol_versioning,
80
81
    )
93
94
        (i.e. the parent directory holding the .bzr directory).
94
95
 
95
96
    Everything in the bzrdir should have the same file permissions.
 
97
 
 
98
    :cvar hooks: An instance of BzrDirHooks.
96
99
    """
97
100
 
98
101
    def break_lock(self):
806
809
        :param transport: Transport containing the bzrdir.
807
810
        :param _unsupported: private.
808
811
        """
 
812
        for hook in BzrDir.hooks['pre_open']:
 
813
            hook(transport)
809
814
        # Keep initial base since 'transport' may be modified while following
810
815
        # the redirections.
811
816
        base = transport.base
1190
1195
        return result
1191
1196
 
1192
1197
 
 
1198
class BzrDirHooks(hooks.Hooks):
 
1199
    """Hooks for BzrDir operations."""
 
1200
 
 
1201
    def __init__(self):
 
1202
        """Create the default hooks."""
 
1203
        hooks.Hooks.__init__(self)
 
1204
        self.create_hook(hooks.HookPoint('pre_open',
 
1205
            "Invoked before attempting to open a BzrDir with the transport "
 
1206
            "that the open will use.", (1, 14), None))
 
1207
 
 
1208
# install the default hooks
 
1209
BzrDir.hooks = BzrDirHooks()
 
1210
 
 
1211
 
1193
1212
class BzrDirPreSplitOut(BzrDir):
1194
1213
    """A common class for the all-in-one formats."""
1195
1214