~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-18 19:14:21 UTC
  • mto: (6437.3.12 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120118191421-6s8ma152g5ghgkva
"bzr switch -b" in a standalone tree will now create a colocated branch.

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):