~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
merge bzr 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
# Original author: David Allouche
18
20
 
19
21
from bzrlib import errors, merge, revision
105
107
            b.set_bound_location(to_branch.base)
106
108
            b.set_parent(b.get_master_branch().get_parent())
107
109
        else:
108
 
            raise errors.BzrCommandError(gettext('Cannot switch a branch, '
109
 
                '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.'))
110
121
 
111
122
 
112
123
def _any_local_commits(this_branch, possible_transports):