28

I have been using SourceGear vault for some personal projects and Team Foundation Server for work projects. One thing TFS is missing is a simple feature that Vault has on its check in dialog window.

In the Vault client, you can see if the checked out file changed from the previous version checked in. Here is a screen shot. Notice the column "Details"? That tells you there is a difference. The way this is super helpful is if you have to check out a entire project because you are going to do code re-generation. I'll check out my class library project and then regenerate my CodeSmith templates. Doing this may result in just a few specific files from changing. When I view the pending check-in screen, I see the files that really changed and I can compare to see the impact.

SO... can TFS do this? Maybe there is a 3rd-party tool that will do it for me? Is there a TFS SDK or PowerTool that I have to get. Anyone want to build it?

MADCookie
  • 2,546
  • 3
  • 25
  • 46
  • 1
    I hope you find something, as it is a massive pain in the arse checking each file for changes individually (although I probably would do that to check that the correct changes had been made anyway, most of the time). – Grant Crofton Jul 27 '10 at 21:36

5 Answers5

18

Select all the files in "Pending changes" window and activate the context menu. Then click "Undo..." > "Undo Changes" > "No to All". The files without changes will be rolled back.

Alexander G
  • 1,829
  • 3
  • 20
  • 30
10

Per this page, you can run this command from the Visual Studio Command Prompt.

tfpt uu /noget /r *

You'll need to have TFS Power Tools installed for this to work. Also, make sure you browse to the root of your mapped folder within the command prompt (ie - C:\TFS for example).

TFS Power Tools links (if you don't already have it)
TFS Power Tools for 2010
TFS Power Tools for 2012

WEFX
  • 7,709
  • 8
  • 59
  • 93
  • works like a charm, thanks! very glad I didn't have to undo all 1844 files manually :D – Daniël Tulp Oct 31 '14 at 19:48
  • 1
    Is there no way to automate this? It requires running the command each and every time. I'm sure a place I used to work at had a setup that automatically undo'd unchanged files but I can't figure out a way to do this. – Jez Nov 28 '14 at 12:17
  • I *believe* that unchanged files don't actually get updated in TFS. That could just be the setup at my job. I just like to perform the above operation (in my answer) for my own sanity; to make sure I'm only checking-in files I actually modified. – WEFX Feb 10 '15 at 13:58
  • TFS checks if a file is different before updating it, so it is more an inconvenience than a potential code problem. I check the pending changes to see what I changed in the code and write my check in comment and add the appropriate relating workitems, so having 1800 changed files instead of the 15 I was working on matters to me. – Daniël Tulp Apr 11 '16 at 11:55
7

There is no need to undo the unchanged files, as TFS will notice they're unchanged upon checkin and will only associate the truly changed files. Any files checked out but unchanged are reverted to their last known checked in version and will not be associated with your checkin. It is impossible in TFS (though not very clearly documented) to check in an unchanged file. It will always revert to the previous version if there are no changes.

You can quickly undo your unchanged files by calling 'tfpt.exe uu /r' from the command line (you need to have the Team Foundation Power tools for this) or by using the "Undo unchanged" button in the Pending changes window. This removed any items from the list that are unchanged immediately. So that you can see exactly what you're checking in.

Undo unchanged option

Though it might be that this option is added by the Team Foundation Power Tools or the TFS Source Control Explorer Extensions (which are a must have for every TFS user anyways).

See also:

jessehouwing
  • 87,636
  • 19
  • 214
  • 286
  • I'm using TFS 2010 and when I run tfpt.exe uu /r from the VS Command Prompt it says **Unable to determine the workspace**. Did you get this error too? – Alicia Mar 08 '13 at 03:00
  • Is is the current working folder mapped? If not did you provide the required parameters? – jessehouwing Mar 08 '13 at 18:45
  • 1
    The current working folder was mapped. Overcame my error by navigating (using command prompt) to a folder that was mapped. – Alicia Apr 01 '13 at 22:25
  • How the heck did you get that "Undo unchanged" button in the Pending Changes window? I'm using VS2013, I installed the 2 extensions you linked to, and I still don't see it. – Jez Nov 28 '14 at 12:15
  • In 2013 it has moved to the source control explorer. It's on the toolbar of that window. – jessehouwing Nov 28 '14 at 16:41
4

I don't like answering my own questions, but it looks like there might not be a real Microsoft solution out there. For me, this is how I handle the problem at the office using Visual Studio.

  1. Before I re-generate the business objects, I make a copy of the entire folder structure
  2. I check out the entire project or the root generated folder
  3. I start the code generator. Sometimes, I know exactly what is changing, but other times, I might make a lot of changes and I don't want to miss anything. My code generator at work also generates all the SQL files needed to DROP / CREATE stored procedures.
  4. Using SourceGear DiffMerge, I compare the folders of the just generated and the previously backed up folder.

This is pretty time consuming. I never thought of it as a problem until I saw Vault identifying that a file was different on disk from the repository.

Maybe you all can say how you do code generation / regeneration when working with a source control repository.

Community
  • 1
  • 1
MADCookie
  • 2,546
  • 3
  • 25
  • 46
1

I work in a corporate development environment where many developers may be working on the same file, and we have TFS as our source control as well. In our document of Best Practices for TFS, we really discourage checking out files that the developers don't intend on changing, that way we naturally exclude files without differences when submitting a changeset.

To answer your question, I normally just look at the "Pending Changes" window and run a Compare on the "changed" files that I'm unsure of--the Compare tool should immediately tell you if your local copy is the same as the server copy. Unfortunately, there's no real workaround other than what I suggested, but I don't see the scenario where I absolutely must check out an entire project branch for editing.

danyim
  • 1,222
  • 9
  • 27
  • I'm not sure what you mean by code generation. But on the other hand, I can say that's usually what we developers try to do from 8 to 5 :) – danyim Jul 27 '10 at 22:38
  • Code generation using tools like CodeSmith to generate business object classes based on the schema of a database. If you are not doing this kind of development, then you wouldn't need to check out all the files in a project. It looks like Grant Crofton understands the need. – MADCookie Jul 27 '10 at 23:22
  • Comparing files is good, but what if you have 250 files to compare ? This is happening to me, with updated WCF references. Most of the files are identical, I don't know why TFS had checked out on them. – FrenkyB Oct 23 '15 at 12:55