开发者

Unified Diff in TFS

Anyone know if thi开发者_JAVA技巧s (generating a unified diff) is possible and if so, how?

Thanks.


It's tf diff /shelveset:<set> /format:unified. However, note that unlike most modern version-control systems, TFS can't actually work with patch files afaik. That is, you can't take the result of the diff and apply it to a set of files to get the resulting changes. (What most people do is zip up the files that changed and drop-and-replace that as a "patch". Ick.)


This is what I usually do:

  • Generate a unified diff from tf command line to get a patch file

    tf diff /recursive /format:unified .  >> diff.patch 
    
  • Download patch utility from http://gnuwin32.sourceforge.net/packages/patch.htm

  • Apply patch with

    patch.exe -p0 < diff.patch
    

Obviously this assumes that the source files are already checked out. If they are not, especially when you are applying patches across branches, write a simple shell script to go through the diff file, get the files path and tf edit them.


This is an on-going feature diff (pardon the pun) with SubVersion and others, that is recognised by Microsoft. I believe a solution will appear soon, however until then I have come up with a solution:

  1. Build a windows forms application which will take 4 fields as command-line parameters (filepath1, label1, filepath2, label2) and returns a string unified diff of the two files (maybe output to a rich textbox or something). I have one, but it is a bit rough to put up on CodePlex I believe. There are a few managed Diff libraries.

  2. Set Visual Studio's Source control compare function to point to your diff app. Make sure it opens and compares correctly.

  3. Build a windows forms patch application, which will apply the patch to a folder. The application also has to check out each file as it is patched (fun!).

  4. Setup two workspaces, the usual one, and a MyWkSpace_PATCH. This is used to patch to.

I still have to finish of point 3, but this will give me somewhat similar functionality to SubVersion. Will let you know how point 3 goes!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜