checkin

Forcing a TFS checkin of a file via C#


How can I specify that I ALWAYS want the local file to replace the server copy even if the TFS copy is newer?


if (pendingChanges.GetUpperBound(0)>-1)
   ChangeSetNumber = workspace.CheckIn(pendingChanges, filename);

I can see from the intelisense that I can specify checkinoptions as a parameter of the CheckIn method, I just cannot find what I need to put in to have it always check in and ignore any conflict I might come up with.

Thanks in advance.
EDIT: I found a command TF RESOLVE "item" /auto:AcceptYours /recursive So I guess my revised question would be is there a programming equivalent to the /auto:AcceptYours switch?
NecroEDIT: process the conflicts before doing the checkin

Conflict[] conflicts = workspace.QueryConflicts(new string[] { TFSProject }, true);

foreach (Conflict conflict in conflicts)
{
    conflict.Resolution = Resolution.AcceptTheirs;
    workspace.ResolveConflict(conflict);
}

Solution

  • Checkins are atomic - either they all succeed or they all fail. If there are any conflicts that need to be resolved before the check in, the check in operation will throw an exception. (Documentation)

    You have to evaluate checkin for conflicts and then resolve the CheckinConflicts by Workspace.ResolveConflict Method. ResolveConflict expects CheckinConflict, and result of the EvaluateCheckin (which is CheckinEvaluationResult) includes CheckinConflicts.

    This page may help.

    Note: checkinoptions is not related with what you are asking.

    Hope this helps.