Java TFS SDK - diff two files
-
lundi 20 février 2012 16:20
Hi,
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.
Regards,
Petr

Petr Dousa
- Déplacé John QiaoMicrosoft Contingent Staff mardi 21 février 2012 01:20 (From:Team Foundation Server - General)
Toutes les réponses
-
vendredi 24 février 2012 14:09Propriétaire
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.
- Proposé comme réponse Shaw TerwilligerOwner vendredi 24 février 2012 14:10
- Marqué comme réponse Petr Dousa jeudi 8 mars 2012 12:02
-
vendredi 29 juin 2012 11:07
Dear Shaw,
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);
engine.downloadFileToStream(path, baos);Here, workspace object is NULL.
Can you provide me any clue to make this happen.
Many thanks,
Mohit(
-
mercredi 4 juillet 2012 11:39
Hi
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(),
new DateVersionSpec(Utilities.getCurrentCalendarDate()),
RecursionType.ONE_LEVEL, DeletedState.NON_DELETED,
ItemType.FILE, true);This was my Item had download URL into them & I used
engine.downloadFileToStream(item.getDownloadURL(), baos);
to download file contents
-Mohit

