~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-23 15:31:35 UTC
  • mfrom: (6443.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20120123153135-8v3r3z1lx055vmpl
(jelmer) Merge the 2.5 series 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):