Monday, February 20, 2012 4:20 PM
I've tried to work with Java TFS SDK API. It works fine. But I'm not able to find how to get unified diff of two files as it is possible for .NET API (http://blogs.msdn.com/b/buckh/archive/2006/04/06/project-diff.aspx)
So my question is: Is there a possibility how to get diff of two code changes? I need to get count of changed files and count of changed lines.
Thanks in advance for your reply.
- Moved by John QiaoMicrosoft Contingent Staff Tuesday, February 21, 2012 1:20 AM (From:Team Foundation Server - General)
Friday, February 24, 2012 2:09 PMOwner
The high level approach described in Buck's blog post is also the right approach for the Java SDK, but you'll have to implement the DiffFiles method another way. The TFS SDK for Java doesn't contain DiffItem and DiffItemVersionedFile. Those classes are in the TEE CLC product, not part of the SDK libraries.
Implementing your own replacement is pretty straightforward. You'll need to download the content from the Item to some local file (GetEngine.downloadFileToTempLocation() can help here, you can pass it the result of Item.getDownloadURL()). Then you launch your diff tool, however you want to configure it.
For an better experience, our DiffItem classes create temp files with names that mix together the Item's name and version. This allows the diff tools to show differences for "file.txt;C123" instead of just "abc123456.tmp". Our classes also compute some label strings that can be passed to diff tools, for even more information. You would have to construct these if you want them (from more information in the Item class), or just not pass them to your diff tool.
Friday, June 29, 2012 11:07 AM
My objective is to read contents of a file.
Referring to your last note, I tried to create object of GetEngine but failed to get object of Workspace.
VersionControlClient vcc = tpc.getVersionControlClient();
Workspace workSpace = vcc.getWorkspace("C:\\RTM\\");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GetEngine engine = new GetEngine(vcc, workSpace);
Here, workspace object is NULL.
Can you provide me any clue to make this happen.
Wednesday, July 04, 2012 11:39 AM
I have successfully read contents of file in InputStream.
I was getting downloadUrl = null & I corrected it bt getting ItemSet using different method of VCC.
This method had parameter 'downloadInfo' as true.
ItemSet itemSet = vcc.getItems(document.getRepositoryAddress(),
This was my Item had download URL into them & I used
to download file contents