switch --force on lightweight checkout connects to original remote branch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Medium
|
Unassigned |
Bug Description
When switching a lightweight checkout from referencing one remote branch to another (remote or local) branch, bzr attempts to connect to the original branch despite using --force.
This means that if you have a lightweight checkout from a branch on a server that goes down and wish to switch to the branch on the backup server, bzr switch --force will fail.
To recreate:
Create a lightweight checkout from a remote branch over sftp (that you do not have public key authentication for), ie:
bzr checkout --lightweight sftp://
Create a copy of the branch somewhere not on the server (can be local or remote).
Attempt to switch --force to copy of branch
bzr switch --force sftp://
Bzr will ask for sftp login for branch you are trying to switch *from* (it will do this after first asking for the sftp login for the branch you are switching to, if it is also remote).
Tested with bzr 1.6.1 and 1.9~bzr8.10-3782-1.
tags: | added: switch |
It looks like this is the problem, in bzrlib/switch.py.
In the function _check_ pending_ merges:
try: open_workingtre e() NotBranchError, ex:
tree = control.
except errors.
# Lightweight checkout and branch is no longer there
if force:
return
else:
raise ex
It always attempts to open the working tree to check for pending merges. If it finds the branch has disappeared and this is a lightweight checkout, it either raises an exception or if --force is used, just ignores it.
The problem is that if the working tree is remote and the server is no longer there/whatever, it fails at the connecting stage. ie with:
"ERROR: Unable to connect to SSH host XXX.XXX.XXX.XXX"