~bzr-pqm/bzr/2.5

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-19 15:03:38 UTC
  • mfrom: (6444.2.6 switch-new-colo-branch)
  • Revision ID: pqm@pqm.ubuntu.com-20120119150338-i8nablep809146e1
(jelmer) Support switching a colocated branch in a standalone branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
            b.set_bound_location(to_branch.base)
108
108
            b.set_parent(b.get_master_branch().get_parent())
109
109
        else:
110
 
            raise errors.BzrCommandError(gettext('Cannot switch a branch, '
111
 
                'only a checkout.'))
 
110
            # If this is a standalone tree and the new branch
 
111
            # is derived from this one, create a lightweight checkout.
 
112
            graph = b.repository.get_graph(to_branch.repository)
 
113
            if (b.bzrdir._format.colocated_branches and
 
114
                 (force or graph.is_ancestor(b.last_revision(),
 
115
                    to_branch.last_revision()))):
 
116
                b.bzrdir.destroy_branch()
 
117
                b.bzrdir.set_branch_reference(to_branch, name="")
 
118
            else:
 
119
                raise errors.BzrCommandError(gettext('Cannot switch a branch, '
 
120
                    'only a checkout.'))
112
121
 
113
122
 
114
123
def _any_local_commits(this_branch, possible_transports):