Problem

Today I tried to move VS2005 solution in TFS source control from one Source Control location to another (on the same server) as I had put it in a stupid location to start with.

So I unbound the source control (File -> Source Control -> Change Source Control) and then went into Source Control Explorer and deleted the directory and then committed the pending delete. This removed the files in the source control BUT ALSO the local ones on my disk, due to the workspace mapping. This was not what I expected, you use source control so you always have copy, a safety net, I had just lost all of my copies by using source control!

The immediate fix

So I checked the recycle bin and nothing, so I knew I had to use the TFS Power Tools to sort this out. The command required is

tftp rollback

The problem here is that you have to be in a directory that is mapped in your workspace so it can poll your TFS server to find projects. So I changed directory to my C:projectmyproject and ran the tool. It does a get latest against the server then shows a dialog where you can find the changeset to rollback to. I selected the one with the project deletes and hit go and it errored. It said 

Postponing undelete to wait for the filename C:projectsmyproject no longer be occupied.

It turns out that as the changeset included a directory delete tfpt must be able to create the directory, which it could not do as it already existed and I was running the tftp.exe from it.

So I had to change directory to one also in the workspace but not for this solution, and also rename or delete the old directory  and then the command worked OK.

Once this was done I was at least back to where I started. I get get all my files, build the project and check in and out.

How it should be done

The way it should have moved the project, assuming I did not care about the change history, is as follows

  1. In VS2005 load the solution then - file -> source control -> change source control -> unbind the project
  2. The select the solution or project in solution explorer and - file -> source control -> add selected projects to source control. The key point is here you are asked if you want to use the old location or a new one. This option is not should if you do not go via the file menu. Pick a new location.
  3. Once it is moved this way the old branch can be removed. Note that you will have to map the old location to the local disk in the workspace so that the delete options become enabled.

Hope this saves someone a bit of time.