~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-22 17:08:27 UTC
  • mfrom: (5107.3.8 new_branch_and_repo_hooks)
  • Revision ID: pqm@pqm.ubuntu.com-20100422170827-h0bb41yq5nkosu6t
(vila) Add 'post_repo_init', 'post_branch_init' and 'post_switch' hooks. (Marco Pantaleoni)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.trace import note
23
23
 
24
24
 
 
25
def _run_post_switch_hooks(control_dir, to_branch, force, revision_id):
 
26
    from bzrlib.branch import SwitchHookParams
 
27
    hooks = Branch.hooks['post_switch']
 
28
    if not hooks:
 
29
        return
 
30
    params = SwitchHookParams(control_dir, to_branch, force, revision_id)
 
31
    for hook in hooks:
 
32
        hook(params)
 
33
 
25
34
def switch(control_dir, to_branch, force=False, quiet=False, revision_id=None):
26
35
    """Switch the branch associated with a checkout.
27
36
 
38
47
    _set_branch_location(control_dir, to_branch, force)
39
48
    tree = control_dir.open_workingtree()
40
49
    _update(tree, source_repository, quiet, revision_id)
41
 
 
 
50
    _run_post_switch_hooks(control_dir, to_branch, force, revision_id)
42
51
 
43
52
def _check_pending_merges(control, force=False):
44
53
    """Check that there are no outstanding pending merges before switching.