TFS API Pending Items, Exclude list, Include List RRS feed

  • Question

  • Hello


    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))
              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


    Friday, December 6, 2019 7:00 PM

All replies

  • https://stackoverflow.com/questions/tagged/tfs

    It's where you should post.

    Friday, December 6, 2019 9:04 PM