/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: Ian Clatworthy
  • Date: 2007-12-07 04:51:58 UTC
  • mto: (3092.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3093.
  • Revision ID: ian.clatworthy@internode.on.net-20071207045158-y91slghnuoa7klfd
make switch fail without --force if branch missing

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    :param to_branch: branch that the checkout is to reference
30
30
    :param force: skip the check for local commits in a heavy checkout
31
31
    """
32
 
    _check_pending_merges(control_dir)
 
32
    _check_pending_merges(control_dir, force)
33
33
    try:
34
34
        source_repository = control_dir.open_branch().repository
35
35
    except errors.NotBranchError:
39
39
    _update(tree, source_repository)
40
40
 
41
41
 
42
 
def _check_pending_merges(control):
 
42
def _check_pending_merges(control, force=False):
43
43
    """Check that there are no outstanding pending merges before switching.
44
44
 
45
45
    :param control: BzrDir of the branch to check
46
46
    """
47
47
    try:
48
48
        tree = control.open_workingtree()
49
 
    except errors.NotBranchError:
50
 
        # old branch is gone
51
 
        return
 
49
    except errors.NotBranchError, ex:
 
50
        if force:
 
51
            return
 
52
        else:
 
53
            raise ex
52
54
    # XXX: Should the tree be locked for get_parent_ids?
53
55
    existing_pending_merges = tree.get_parent_ids()[1:]
54
56
    if len(existing_pending_merges) > 0: