/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/switch.py

  • Committer: Marco Pantaleoni
  • Date: 2010-03-24 14:35:25 UTC
  • mto: This revision was merged to the branch mainline in revision 5174.
  • Revision ID: panta@elasticworld.org-20100324143525-00sej430c23d3gto
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init',
called respectively whenever a new branch is created, when a checkout is
switched to a different branch and when a repository is initialized
(created).

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
    if Branch.hooks['post_switch']:
 
51
        _run_post_switch_hooks(control_dir, to_branch, force, revision_id)
42
52
 
43
53
def _check_pending_merges(control, force=False):
44
54
    """Check that there are no outstanding pending merges before switching.