TFS API待处理项目,排除列表,包含列表

问题描述 投票:0回答:1

背景

我正在制作TFS合并工具来满足开发和分支机构的要求。

有了这个工具,我就有了一个使用Microsoft.Teamfoundation.ExtendedClient软件包的业务对象层。

我有什么

我目前有一个功能可以对我的待处理商品进行检入

'changes'对象包含我所有的更改。包含和排除

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

我需要什么我只需要获取他的“已包含”待处理更改列表。

有人建议使用,但由于ITS仅具有零行,因此会失败。

//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);
      }
    }

我也尝试过此方法,但SavedCheckin = null,但出现异常。

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

因此,我需要遍历“更改”列表并删除“排除”的项目

或这里肯定缺少某些东西。

预先感谢

艾伦

tfs checkin changeset
1个回答
0
投票

[没有TFS API仅获得Included changes,在Visual Studio / Team Explorer中存在Included/Excluded changes节。 Visual Studio会检测到您在系统外部进行的更改。

您需要的是Visual Studio Extension API-IPendingChangesExt Interface,您可以参考下面的文章或在Visual Studio Extension方面打开一个包装盒。

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

© www.soinside.com 2019 - 2024. All rights reserved.