none
Java TFS SDK - diff two files

Antworten

  • 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.

    Freitag, 24. Februar 2012 14:09

Alle Antworten

  • 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.

    Freitag, 24. Februar 2012 14:09
  • 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

    (

    Freitag, 29. Juni 2012 11:07
  • 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

    Mittwoch, 4. Juli 2012 11:39