How to: Diff Shelved Files?

You can run:

tf diff /shelveset:shelvesetName;DOMAIN\ownerUserName

Please note that this will diff the shelved changes against the unmodified version, not necessarily the latest version, just like what the you get from clicking compare in the shelveset details dialog.

If you want to diff the shelved files programmatically against the latest version, you will need to write some code, please take a look at: https://blogs.msdn.com/mohamedg/archive/2009/03/08/how-to-diff-files-using-tfs-apis.aspx. If you are going to use the Difference class to launch a diff tool, you can use Difference.VisualDiffItems.

If you need to get the differences in a linked list of DiffSegments, you will need to unshelve the shelved file (fileA) and download the latest from server (fileB) to disk first, then diff them using the following call:

 Difference.DiffFiles(fileA, FileType.Detect(fileA, null), fileB, FileType.Detect(fileB, null), new DiffOptions());

Comments