Forgot to shelve my code in TFS. What are my options now? - visual-studio-2010

I made some code changes (in VS 2010), and did not check in or shelve my latest changes. Unfortunately, my laptop had a heating problem and I can't use it for another week (it's going for service). I have the hard drive with me though, so I can probably access the code from another machine. But how do I do it without messing up the state in TFS? If I copy-paste all my code from the hard drive into the other machine, VS will check out all my files right? Is there a better way to do this?
Thanks!

I would check the files out that you think are changed (you can use a tool like WinMerge to see which files have changed), copy the updated files from the old drive, and shelve or check them back in.

If the files are in a solution and you have the complete structure on your disk try if the "Go online" feature is available if you open the solution.
"File => SourceControl => Go online" or go to another machine and map your workspace to your disk with the changed source code.
(I would create a temporary private workspace for that situation and delete it after successfull merging/checkin).
I suppose if you open the solution and it has a valid source control binding, you get a message that your solution is right to go online.
If this dialog appears select "yes", all changes are correctly detected and you can merge/checkin in the normal way.

On the new machine get the latest code from branch, which comes with previously checked-out TFS version by you, then copy/paste the files from harddisk to replace tfs verison.

Related

TFS 2012 not detecting deleted files in pending changes

We have multiple developers on our team. This works for everyone except one developer, but we cannot seem to find the reason it does not work for this individual. We all have VS premium+, TFS 2012 power tools installed.
We have a branch. We get latest version from branch. Go to windows explorer and delete all files in folder "sdk" (there exist no subdirectories in sdk/). Then we copy into it a bunch of files. (This effectively leaves some files as new files, updated files, identical files or removed files when compared with what was deleted.)
When we go to pending changes, these changes show up under "Excluded Changes - Add(s) 51, Deletes(3)".
Except for one developer. His system does not recognize these changes. What might cause this to not work for him?
If it helps troubleshoot, he is also the only developer that if he were to delete these files via power tools delete option in windows explorer, his .dll files get locked. This does not happen for anyone else either.
This is what we've checked so far:
EDIT: Solution Found - Thank you all for the responses! It was indeed the local vs server workspace option. Setting his workspace to local solved these and a few other issue he was apparently having.
Make sure that the developer is using a "Local Workspace" as opposed to the "Server Workspace".
This is a concept which was introduced in TFS 2012 which helps developers to work offline as opposed to server workspace in earlier versions which did not allow that. TFS 2012 changes up the workspace options. Server workspaces are still available, and work exactly has they have in previous versions. However, TFS 2012 now contains a new type of workspace, called a Local workspace. Again, this is an oversimplification, but in a Local workspace, all the files are read/write, not read-only. The meta-data about the files is stored in a hidden folder in the root of the workspace, which allows edits, renames and deletes to be done locally without any communication to the server.
This improves the offline story with TFS significantly, as you no longer encounter issues with editing read-only files. It also makes it easier to work with other tools (such as Notepad) to edit code files. Making a change to a code file using Notepad will still mark that file as edited, which will be picked up by TFS the next time you connect.
LINK
This only ever happens when a user tampers with a local view of source control (be it a local workspace, or not). If all you ever did was get latest from TFS this would never occur, instead, the local view of what is in TFS would always be properly managed.
Also sounds like a bad merge, e.g. getting latest (where the files no longer exist) then copying in old content (introducing untracked files.) One thing you might try doing to correct the issue is doing a forced fetch from TFS after deleting the local workspace contents BEFORE attempting a merge. This will ensure that the local workspace is up to date an accurate with what the TFS server believes is truth, if it still occurs after merging in content then the problem is almost certainly within the merge process the user is going through (i.e. PEBKAC, or a knowledge gap about what they are doing.)
If you unshelve old content (pre-deletion) into the local workspace (where the deletions have already been performed, according to the SCC, and thus locally because of a sync/get-latest) then the unshelved files will effectively become untracked and it's up to the user to clean up the mess. This is identical to a user having copied loose files into their workspace that TFS never had any knowledge of. TFS isn't going to prune untracked files for you, I believe some other source control tools might do this as a configurable default, TFS does not.
That this is only happening to one developer in the team suggests that the other developers, one at a time, should sit with this developer and drive using "their process" to see if it still occurs for them. More often than not this comes down to a bad process a user has adopted, and putting a different person in the chair can help highlight why it has been occurring and help end it. A disciplined build/source manager and/or developer should not experience this problem.
Very interested in knowing what the problem turns out to be.

TFS re-add Visual Studio 2010 project

I have a project that is source controlled using TFS. I was doing some coding on my laptop when, unfortunately, my computer crashed and I ended up having to re-install Windows. I was afraid that all my code would be lost, but thankfully I was able to restore the code files.
My problem is that now I need to commit the changes to TFS. Currently the projects do not have any source bindings. I can't overwrite the current code base because there is work that has been done since my crash by other devs.
How can I add the changes I've made to TFS?
The way i've done something like this is kinda hackish, but what i usually do is get latest from TFS onto my laptop, and checkout all of the code from the project in question. Then i take the changed code and copy it over that folder, check it in. TFS should be smart enough to only really affect the actual code items that have been changed. You can see in the history the actual files that got changed to be sure.
If you know the exact files that you need to update, then that will make things much easier, because you can do the above steps, but then just check out the particular files you know of. You can do a compare between them and your new code to make sure that you don't overwrite anything your other programmers have done. Again, hackish, but i don't know of any streamlined way to do this.
You might want to make sure that you download the TFS visual studio extension, since that will give you rollback capability.

Is working together possible when using Team Foundation Server?

If one chooses to "prevent other users from checking out and checking in" from Team Foundation Server:
Can anyone reach the code?
Is there any way to work from another user's computer?
How about shelving?
I would interpret that sort of lock as meaning that someone is going to do something so destructive that it is in your interests to not have an edited copy when that happens. If you think it is a mistake, talk to the person who locked the file.
An option, if you really want to do this, is to remove the readonly attribute on the file yourself (in Windows Explorer or through a shell) and edit the file. That is a good way to cause yourself trouble, though, if the file is going to be changed substantially by the person that locked it. Also, you will need to later mark it as checked out in TFS to actually check it in.
I do not think you will be able to shelve the file (unless you follow the option below) since you will not be able to check it out for edit.
One last option is that you could branch the file, work on the branch, and then merge it back in later. Once again, though, that may be difficult if the edits by the person locking the file are going to be extensive.
I'm not sure I understood all of your questions, but I'll give it a chance:
If by reach you mean, get latest version and read, yes they could. But they wouldn't be able to change the code while it's locked unless they circumvent Visual Studio and change the read-only attribute of the with the command-prompt, Windows Explorer etc.
Visual Studio and TFS 2010 introduces the concept of permissions on workspaces. A workspace now can be private (the old behavior), public limited or public. Using a public workspace, on could edit the files in the workspace of another person. See tf workspace /permission for more information.
You can shelve anything that is in your workspace regardless of locks on anybody's workspaces.
Here is a link to the permission values for TFS
http://msdn.microsoft.com/en-us/library/ms252587.aspx
This should answer your questions

TFS: How do I cleanup the messed up server?

I'm using TFS to connect to codeplex.com. The source version of the project is messed up, and I want to replace it. Found a way to delete the project, but it won't let me delete it. How can I say delete all of the subprojects without deleting the representative folders on the hard drive?
Note: this is codeplex so I have limited issues.
Thanks.
If I understand the question correctly, you want to delete the folders on the server but not delete anything locally. You then want to re-add your code using what you have locally. Is that correct?
Possibly the easiest way to do this is to copy the code you have locally into a separate back-up folder on your desktop. Then perform a delete using Source Control Explorer in Visual Studio. Check-in the delete. Finally drag/drop the contents of your local back-up into Source Control Explorer (you need Visual Studio 2008 SP1 for drag/drop to work) so that it adds the appropriate files for you to.
Check the pending adds that you have to make sure all the files you want are included and no files you do not want (i.e. make sure any compilation outputs are not included and that the folder format in source control explorer is how you want it to be)
Once you are happy, check-in your adds.
Let me know if I didn't understand the question correctly.
I would recommend against doing that. TFS can get confused by deleting and re-adding. At least, that is the case if you have any branching & merging to do. If not... well, go ahead.

Incorrect states on TFS 2008 Project Files

I have a project stored in TFS Source Control (2008) that is being worked on by 2 developers. All 3 versions (Developer1, Developer2 and Server) are up to date with each other. However, both Developers report that some files in Solution Explorer say 'Checked out by someone else or in another place' - but the same files viewed in Source Control Explorer say they are available. It seems as though the workspaces have gotten confused but the actual files are 'good'.
Can anyone help?
I've had these lists get out of sync before. What was required was a "Force Get Latest" to refresh the statuses. To do that, you select "Get a specific version", and then select "Latest" and "Get file even if they already exist locally" (or some option like that). This will force the files to refresh, even if they're already up to date, and should also correct their status.
You would think VS/TFS would be smart enough to reconcile this on their own, but sometimes they just don't, for whatever reason.
If I check out the file and then do a "Undo pending changes" it goes back to normal. I think it's this bug, and it doesn't seem to be fixed in any patches or a future version yet.
http://social.msdn.microsoft.com/Forums/en-SG/tfsversioncontrol/thread/2a1c6a8c-0a2b-460c-9335-e31598f1107b
Go to File->Source Control->Workspaces in Visual Studio. Make sure that the devs you have only have 1 workspace. It's likely that someone has created multiple workspaces on his machine and have files checked out there.
TFS maps workspaces to locations on the machine they are created on so if someone pulled down code to multiple places and edited it, you can have one person with code checked out in multiple places.
Also, this link shows you how to see all the files checked out for a particular person.
But I also agree with Preet. It's perfectly OK to have the file checked out by more than one person in TFS. That's one of the minor improvements over SourceSafe.
Do you have SP1 installed? This fixed it for our team. If not, check if any of your devs have separate workspaces and may have checked out files to it
We had this problem when we upgraded from TFS 2005 to TFS 2008. There were problems with the upgrade that forced us to create a new virtual machine and restore/upgrade the 2005 database. We were under workgroup authentication and re-created local user accounts but since they all had new SIDs they were considered different accounts in some respects. All of the original users' workspaces hung around.
Take a look at the commandline tf and tfpt tools for manipulating workspaces, see if you have something orphaned. Attrice Team Foundation Sidekicks has a nice GUI workspaces manager too.
A bigger question. Why do you care if someone else has a file checked out? TFS supports multiple parallel checkouts on files. If you want exclusive control then use a lock.
Sorry to be clearer - I often find that the state in Solution explorer is not worth looking at. If I need a file I check it out. If someone's locked it then I have get told by TFS at that time, otherwise I just work with the file.

Resources