Workspaces: Updating the owner

sourcecontrol
15234

Recently we changed our internal domain. It was a little bit of a pain, since I had to migrate my setting and preferences. One “snag” I hit was reconnecting to TFS once I had changed my primary login from the old domain to the new domain.

If you change your username (or domain), open Visual Studio and go to the Source Control Explorer, you’ll see that (of course) you don’t have any mappings in your default workspace. If you try to create a mapping to an existing folder on your hard-drive, you’ll get an error stating that the folder is mapped in another workspace:

image

So you drop into the Visual Studio command prompt and use the tf.exe command to list the workspaces:

tf workspaces

image

However (and this may be a bug, I’m not sure), this only brings back workspaces for the current user (on the new domain). So if you want to see all the workspaces (for any user) you’ll have to enter this command:

tf workspaces /collection:tpcUrl /owner:*

(Of course tpcUrl is the url of your team project collection).

image

Now that you can see all the workspaces, you’ll want to update the owner of the old workspace.

tf workspace /name:workspacename;workspaceowner /collection:tpcUrl

This launches the dialogue for the workspace properties. So I tried to just update the name in the owner field, but there were pending changes in the workspace, so I got an error message:

image

Back to the console. To see the pending changes in the old workspace change dir to the root of your workspace mapping and run the following command:

tf status /collection:tpcUrl /workspace:workspacename;workspaceowner

This lists all the pending changes. Now from the list of changes, I could see some that I wanted to keep and others that I didn’t – but I didn’t want to think about sorting the changes out now. So I decided to follow the previous error log’s advice and shelve the pending changes.

To “select” the old workspace from the command prompt, run the tf workspace command:

tf workspace /name:workspacename;workspaceowner /collection:tpcUrl

When the dialogue opens, change the “Permissions” to Public (if it’s not set already) to make sure that the new user can shelve in the old user’s workspace and press the OK button.

image

Now you can run the shelve command:

tf shelve /recursive name;owner *.* /move

(Here name is the name of the shelveset and owner is the domain\username of the new user)

The shelve dialogue opens, so you can review the shelveset. Press Shelve to complete the operation.

Now run the workspace command again, and change the owner:

image

(I had to rename the new workspace since it had the same name as the old one before this worked).

Finally, to get the pending changes back, you need to unshelve. Open the Pending Changes window (View->Other Windows->Pending Changes in VS) and press the Unshelve button. Find the shelveset that you saved the pending changes in and select it. Then hit Unshelve and your pending changes are back.

Now your workspace is updated to the new user, and you can get back to work!