631
631
return checkout.create_workingtree(revision_id)
634
class BranchHooks(dict):
635
"""A dictionary mapping hook name to a list of callables for branch hooks.
637
e.g. ['set_rh'] Is the list of items to be called when the
638
set_revision_history function is invoked.
642
"""Create the default hooks.
644
These are all empty initially, because by default nothing should get
648
# invoked whenever the revision history has been set
649
# with set_revision_history. The api signature is
650
# (branch, revision_history), and the branch will
654
# install the default hooks into the class.
655
Branch.hooks = BranchHooks()
658
634
class BranchFormat(object):
659
635
"""An encapsulation of the initialization and open routines for a format.
742
718
return self.get_format_string().rstrip()
721
class BranchHooks(dict):
722
"""A dictionary mapping hook name to a list of callables for branch hooks.
724
e.g. ['set_rh'] Is the list of items to be called when the
725
set_revision_history function is invoked.
729
"""Create the default hooks.
731
These are all empty initially, because by default nothing should get
735
# invoked whenever the revision history has been set
736
# with set_revision_history. The api signature is
737
# (branch, revision_history), and the branch will
738
# be write-locked. Introduced in 0.15.
741
def install_hook(self, hook_name, a_callable):
742
"""Install a_callable in to the hook hook_name.
744
:param hook_name: A hook name. See the __init__ method of BranchHooks
745
for the complete list of hooks.
746
:param a_callable: The callable to be invoked when the hook triggers.
747
The exact signature will depend on the hook - see the __init__
748
method of BranchHooks for details on each hook.
751
self[hook_name].append(a_callable)
753
raise errors.UnknownHook('branch', hook_name)
756
# install the default hooks into the Branch class.
757
Branch.hooks = BranchHooks()
745
760
class BzrBranchFormat4(BranchFormat):
746
761
"""Bzr branch format 4.