62

Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select Create Patch. But for the life of me, I can't find this functionality in TFS. Is this possible?

If not, what's the standard way to submit patches in open source TFS hosted projects (a la CodePlex)?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
swilliams
  • 48,060
  • 27
  • 100
  • 130

3 Answers3

56
tf diff /shelveset:shelveset /format:unified

Edit: This writes to standard output. You can pipe the output to a file.

For more options, see Difference Command.

Ilya
  • 5,533
  • 2
  • 29
  • 57
Curt Hagenlocher
  • 20,680
  • 8
  • 60
  • 50
  • 6
    Can you explain a bit more? 1. How would you apply this patch? 2. Also, if the project is read-only to the patcher, he can't create a shelveset, can he? – Doron Yaacoby Jan 12 '10 at 14:01
  • 1
    There's a standard UNIX program called "patch" that applies unified diffs to source trees. I'm sure you could find a Windows implementation, or you could use Cygwin. – Curt Hagenlocher Jan 31 '10 at 17:56
  • @Doron this displays all differences between the shelveset and the current workspace folder in a format similar to: http://hg.shrinkrays.net/spruce/changeset/0d00e3c15e2c/raw/spruce-0d00e3c15e2c.diff – Chris S Jan 27 '11 at 14:47
  • How do you pipe `|` to a file? I thought you had to redirect `>` to a file. – JJS Jun 06 '14 at 02:31
  • 1
    If you haven't done this before: In the Start menu, drill down to Visual Studio, Tools, Command Prompt. Then cd to a folder somewhere in the local tree of the workspace, e.g. c:\build\myProject\src – Spike0xff Jul 07 '14 at 20:07
2

Because TFS doesn't natively support patch files, the most common thing I see people do on CodePlex is simply zip the modified files and upload the zip. The project coordinator then does a diff against their own checkout.

However since CodePlex also supports TortoiseSVN, more and more people are using that to create their patch files.

jwanagel
  • 4,078
  • 1
  • 25
  • 33
0

I wrote a blog post about a similar issue where I used the TF.exe command and 7Zip to create a TFS patch file that could then be applied on another TFS server or workspace. I posted the the Powershell scripts at Github, which can be used to Zip up any pending changes on one workspace and then apply them to a different server. It would have to be modified to use a changeset instead of pending changes, but that shouldn't be too difficult to accomplish.

Greg Bray
  • 14,929
  • 12
  • 80
  • 104
  • 3
    This script uses the whole file, not the diffed lines. More of a controlled xcopy – JJS Nov 03 '15 at 14:44