/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2007-04-01 06:19:16 UTC
  • mfrom: (2323.5.20 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: mbp@sourcefrog.net-20070401061916-plpgsxdf8g7gll9o
Merge 0.15 final release back to trunk, including: recommend upgrades of old workingtrees, handle multiple http redirections, some dirstate fixes, 

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                           NotBranchError, UninitializableFormat,
55
55
                           UnlistableStore, UnlistableBranch,
56
56
                           )
57
 
from bzrlib.hooks import Hooks
58
57
from bzrlib.symbol_versioning import (deprecated_function,
59
58
                                      deprecated_method,
60
59
                                      DEPRECATED_PARAMETER,
195
194
    def get_physical_lock_status(self):
196
195
        raise NotImplementedError(self.get_physical_lock_status)
197
196
 
198
 
    def leave_lock_in_place(self):
199
 
        """Tell this branch object not to release the physical lock when this
200
 
        object is unlocked.
201
 
        
202
 
        If lock_write doesn't return a token, then this method is not supported.
203
 
        """
204
 
        self.control_files.leave_in_place()
205
 
 
206
 
    def dont_leave_lock_in_place(self):
207
 
        """Tell this branch object to release the physical lock when this
208
 
        object is unlocked, even if it didn't originally acquire it.
209
 
 
210
 
        If lock_write doesn't return a token, then this method is not supported.
211
 
        """
212
 
        self.control_files.dont_leave_in_place()
213
 
 
214
197
    def abspath(self, name):
215
198
        """Return absolute filename for something in the branch
216
199
        
909
892
            control_files.unlock()
910
893
 
911
894
 
912
 
class BranchHooks(Hooks):
 
895
class BranchHooks(dict):
913
896
    """A dictionary mapping hook name to a list of callables for branch hooks.
914
897
    
915
898
    e.g. ['set_rh'] Is the list of items to be called when the
922
905
        These are all empty initially, because by default nothing should get
923
906
        notified.
924
907
        """
925
 
        Hooks.__init__(self)
 
908
        dict.__init__(self)
926
909
        # Introduced in 0.15:
927
910
        # invoked whenever the revision history has been set
928
911
        # with set_revision_history. The api signature is
961
944
        # and an empty branch recieves new_revno of 0, new_revid of None.
962
945
        self['post_uncommit'] = []
963
946
 
 
947
    def install_hook(self, hook_name, a_callable):
 
948
        """Install a_callable in to the hook hook_name.
 
949
 
 
950
        :param hook_name: A hook name. See the __init__ method of BranchHooks
 
951
            for the complete list of hooks.
 
952
        :param a_callable: The callable to be invoked when the hook triggers.
 
953
            The exact signature will depend on the hook - see the __init__ 
 
954
            method of BranchHooks for details on each hook.
 
955
        """
 
956
        try:
 
957
            self[hook_name].append(a_callable)
 
958
        except KeyError:
 
959
            raise errors.UnknownHook('branch', hook_name)
 
960
 
964
961
 
965
962
# install the default hooks into the Branch class.
966
963
Branch.hooks = BranchHooks()
1239
1236
    def is_locked(self):
1240
1237
        return self.control_files.is_locked()
1241
1238
 
1242
 
    def lock_write(self, token=None):
1243
 
        repo_token = self.repository.lock_write()
 
1239
    def lock_write(self):
 
1240
        self.repository.lock_write()
1244
1241
        try:
1245
 
            token = self.control_files.lock_write(token=token)
 
1242
            self.control_files.lock_write()
1246
1243
        except:
1247
1244
            self.repository.unlock()
1248
1245
            raise
1249
 
        return token
1250
1246
 
1251
1247
    def lock_read(self):
1252
1248
        self.repository.lock_read()