0

Background,

I am making a TFS merge tool to service out development and Branch requirements.

Withing this tool I have a business object layer that uses the Microsoft.Teamfoundation.ExtendedClient Package.

What I have

I currently have a function that does the checkin for my pending items

The 'changes' object has all my changes in it. Included and Excluded

 Workspace workspace = _vcs.GetWorkspace(_workspaceName, _workspaceOwner);
 WorkItemCheckinInfo checkInInfo = new WorkItemCheckinInfo(pbi, WorkItemCheckinAction.Associate);
 PendingChange[] changes = workspace.GetPendingChanges();
 ChangesetID = workspace.CheckIn(changes, checkInComment, null, new WorkItemCheckinInfo[] { 
 checkInInfo }, null);

What I need I need to only get his list of 'Included' Pending changes.

Some have suggested using, bu this fails as ITS only has zero rows.

//get all candidate changes and promote them to included changes
PendingChange[] candidateChanges = null;
string serverPath = workspace.GetServerItemForLocalItem(_workspaceName);
List<ItemSpec> its = new List<ItemSpec>();
its.Add(new ItemSpec(serverPath, RecursionType.Full));
workspace.GetPendingChangesWithCandidates(its.ToArray(), true, out candidateChanges);

    foreach (var change in candidateChanges)
    {
      if (change.IsAdd)
      {
        //ws.PendAdd(change.LocalItem);
      }
      else if (change.IsDelete)
      {
        //ws.PendDelete(change.LocalItem);
      }
    }

I have also tried this but SavedCheckin = null and i get an exception.

    SavedCheckin savedCheckin = workspace.LastSavedCheckin;
    //  Create a list of pending changes.
    var pendingAdds = new List<PendingChange>(workspace.GetPendingChanges());
    List<PendingChange> excludedChanges = new List<PendingChange>();
    for (int i = 0; i <= changes.Length - 1; i++)
    {
      if (savedCheckin.IsExcluded(changes[i].ServerItem))
      {
        excludedChanges.Add(changes[i]);
      }
      Console.WriteLine(changes[i].LocalItem.ToString() + " Change  " + changes[i].ChangeType)
    }

So I either need to iterate through the 'changes' list and remove 'Excluded' items

or there is bound to be something im missing here.

thanks in advance

Alan

  • Does this answer your question? [how do I determine what items are included pending check-ins programatically?](https://stackoverflow.com/questions/26168976/how-do-i-determine-what-items-are-included-pending-check-ins-programatically) – Shayki Abramczyk Dec 08 '19 at 08:57

1 Answers1

0

There is no TFS API to get only Included changes, Included/Excluded changes sections exist in Visual Studio/Team Explorer. Visual Studio detects changes you make outside the system.

What you need is Visual Studio Extension API -- IPendingChangesExt Interface, you could refer to the article below or open a case on Visual Studio Extension side.

https://www.mztools.com/articles/2015/MZ2015007.aspx

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39