Answered pendEdit in TFS JAVA SDK

  • mardi 21 août 2012 06:29
     
     

    Hi,

    Let me explain a scenario:

    I have created a workspace with local path as C:/Testing and TFS server path as Root/child/testing folder. Now i have added a file called Test using pendAdd and checked in and again used pendEdit on it and everything works fine. After completing my operations i have deleted the workspace as it will simply get pilled up.

    Now again i thought of testing again so i created a workspace with local path as C:/Testing and TFS server path as Root/child/testing folder. Now i have added a file called NewTest using pendAdd and checked in and again used pendEdit on it and everything works fine. After completing i tried to work on my old file Test which is there in the same local folder with same server path but what i notice is it is not letting me edit the file. I am able to find the find the file but it is not letting me edit the file.

    I am attaching the code below can some one please help me with this.


    File newFile = new File("C:/Testing ", "Test");

    VersionControlClient vcc = tpc.getVersionControlClient();

    ItemSet recursiveFileSet = vcc.getItems(newFile.getAbsolutePath(), LatestVersionSpec.INSTANCE, RecursionType.FULL, DeletedState.NON_DELETED, ItemType.FILE, true);


    for(Item item : recursiveFileSet.getItems()) {

    System.out.println(" " + item.getServerItem() + " (" + item.getChangeSetID() + ")");


    int edit = workspace.pendEdit(new String[]{item.getServerItem()}, RecursionType.FULL, LockLevel.CHECKOUT, FileEncoding.getDefaultTextEncoding(),GetOptions.OVERWRITE, PendChangesOptions.GET_LATEST_ON_CHECKOUT);

    System.out.println("Edit file " + item.getServerItem() + " in CS# " + edit);

    }

    Can you please let me know why this pendEdit is not working with old file with the same local and serverpath but working with new file created by the workspace


    Regards,
    Shirish Bhat

Toutes les réponses

  • mardi 21 août 2012 15:12
     
     

    Hi Shirish,

    First, you don't need to delete the TFS workspace, you can simply reuse it. This code that you attached does not fully do what you described, I don't see where you add the file to TFS or where you delete your workspace. From the description, when you deleted the workspace the first time, did the file get deleted from disk? Also when you created the workspace again and did the mapping, you need to do a get, did you do the get before you try to pend the edit. What is the error that you are getting when you try the pendedit for the old file the second time.

    Thanks

    Mireille

  • mercredi 22 août 2012 06:20
     
     

    Hi Mireille,

    Thanks for the reply.

    I have not added the rest of the code as i thought problem is in this part and i am deleting workspace as i dont want to accumulate the workspaces.

    i am going with workspace.get(GetOptions.OVERWRITE) option it has solved the problem.

    But now when i am running the pendEdit it is returning integer value as one(that is file is in edit mode) but when i check in the UI it is not showing me the same.

    And now after i have checked out a file and made some changes in the local how do i checkin a file i am using workspace.checkIn(pendingChanges, comment) which is checking in all the pending changes but i want to checkin just one file.

    Regards,
    Shirish Bhat.

  • mercredi 22 août 2012 16:35
     
     Traitée

    Hi Shirish,

    When you say the UI is not showing you the same, do you mean in source control explorer, you don't see a pending change? In the UI, you need to refresh before you can see the change.

    Please let me know if you have any other questions or issues.

    Thanks

    Mireille