`bzr switch -b xxx` creates new branch first then failed with error: Cannot switch a branch, only a checkout.

Bug #601922 reported by Alexander Belchenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned

Bug Description

Steps to reproduce: create standalone branch, then try to execute `bzr switch -b` in there.

C:\Temp\8>bzr init a
Created a standalone tree (format: 1.9)

C:\Temp\8>cd a
C:\Temp\8\a>

C:\Temp\8\a>bzr mkdir foo
added foo

C:\Temp\8\a>bzr ci -m1
Committing to: C:/Temp/8/a/
added foo
Committed revision 1.

C:\Temp\8\a>bzr switch -b spam
bzr: ERROR: Cannot switch a branch, only a checkout.

At this point bzr has created new branch "spam" in the parent directory of original branch (a).

C:\Temp\8\spam>bzr info
Standalone tree (format: 1.9)
Location:
  branch root: .

Related branches:
  parent branch: C:/Temp/8/a

I think bzr should not create new branch and should check for type of original branch first and fail early with error: Cannot switch a branch, only a checkout.

Because in the case of branch with big and heavy history this is very long and wasteful process.

Vincent Ladeuil (vila)
Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
Martin Pool (mbp)
tags: added: colocated
Revision history for this message
Martin Pool (mbp) wrote :

So in bzr 2.5b5, I do get the error bialix asks for, "BzrCommandError: Cannot switch a branch, only a checkout", and I think the bug as originally filed is fixed... but...

When I did `bzr switch -b` in a newly created development-colo branch, as jelmer recommended in his "call for testing of colocated branch support":

0.121 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/bzrlib/commands.py", line 919, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/commands.py", line 1124, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.7/dist-packages/bzrlib/commands.py", line 672, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.7/dist-packages/bzrlib/commands.py", line 694, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/cleanup.py", line 136, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/cleanup.py", line 166, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/builtins.py", line 6187, in run
    switch.switch(control_dir, to_branch, force, revision_id=revision)
  File "/usr/lib/python2.7/dist-packages/bzrlib/switch.py", line 48, in switch
    _set_branch_location(control_dir, to_branch, force)
  File "/usr/lib/python2.7/dist-packages/bzrlib/switch.py", line 110, in _set_branch_location
    raise errors.BzrCommandError(gettext('Cannot switch a branch, '
BzrCommandError: Cannot switch a branch, only a checkout.

... perhaps this hinges on it being a branch inside a repository directory?

When I tried 'switch' again in trunk, it seems to work, and indeed the code there has recently changed.

However, on bzr trunk tip, it works for colos, but following the original reproduction instructions with plain branches gives a different error:

mbp@joy% cd ~/tmp
mbp@joy% mkchdir 601922
mbp@joy% bzr.trunk init a
Created a standalone tree (format: 2a)
mbp@joy% bzr
mbp@joy% cd a
mbp@joy% bzr.trunk mkdir foo
added foo
mbp@joy% bzr.trunk ci -m1
Committing to: /home/mbp/tmp/601922/a/
added foo
Committed revision 1.
mbp@joy% bzr.trunk switch -b spam
Tree is up to date at revision 1.
Switched to branch: /home/mbp/tmp/601922/a/
mbp@joy% bzr info
bzr: ERROR: <BzrDirMeta1 at 'file:///home/mbp/tmp/601922/a/,branch=spam/'> does not support co-located branches.

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.