Using WorkSpace.CheckIn

Hi,

I'm playing arround with the TeamServer api. I have a small routine that checks out a file or edit using Workspace.PendEdit(). I now want to be able to check a file in, again using the api. Can someone tell me how to use Workspace.Checkin and the PendingChange class

Thanks for the help

Graham


Answer this question

Using WorkSpace.CheckIn

  • vesuvius

    The WorkspaceOwner should be the username of the person who owns the workspace. It's actually not necessary to provide the computer name since our system doesn't allow a user to have two workspaces with the same name.

    I believe the format required is "DOMAIN\username", though you can try with just the username portion, as well.

  • Lorbeckd

    Graham, you just need to get the pending change and pass it to CheckIn().  Here's a snippet from the API overview sample.
    http://blogs.msdn.com/buckh/archive/2005/09/09/463287.aspx

                    // Checkout and modify the file.
                    workspace.PendEdit(fileName);
                    using (StreamWriter sw = new StreamWriter(fileName))
                    {
                        sw.WriteLine("revision 2 of basic.cs");
                    }

                    // Get the pending change and check in the new revision.
                    pendingChanges = workspace.GetPendingChanges();
                    changesetNumber = workspace.CheckIn(pendingChanges, "Modified basic.cs");

    Let me know if you have additional questions.

    Buck

    [Update]  You can find documentation for the Version Control API in the October Visual Studio SDK release.  Once you install it, you can find the Version Control API doc in
    C:\Program Files\Visual Studio 2005 SDK\2005.10\VisualStudioTeamSystemIntegration\Version Control\Object Model (Help 1.x format).zip.

  • MarTim

    Thats a great help Buck, but can I ask one more question please

    I'm writing a custom task to be called from a Team Build. Now, the Team Build has already created a workspace to perform the Get. I want to use that same workspace in my Task to perform a .PendEdit and later a Checkin. To use these two commands I need a workspace instance.

    What I wanted to ask you is; using the API what is the best way to get the workspace instance given a Workspace name (the workspace name will be passed in as a property to my task).

    Regards.

  • Emac80

    Sorry, I have found this method on the Workstation:

    GetLocalWorkspaceInfo( string tfsname, string workspacename, string workspaceowner). What is the WorkspaceOwner param Would it be the computer name the workspace was created on

    Graham

  • Will Strootman

    What happens if there is a conflict that I want to ignore and do the check in anyway How do I force an overwrite on the existing file I guess the other way round is easier, just undo the local changes.

    Thanks a lot


  • Using WorkSpace.CheckIn