如何获得所有未合并的变更使用TFS 2010 SDK的一个分支?分支、如何获得、TFS、SDK

2023-09-06 05:26:40 作者:无人完美

目前我有两个分支 - 开发和发布。

Currently I have 2 branches - Development and Release.

是否有可能获得发展的所有未合并的变更来释放?

Is it possible to obtain all unmerged changesets from Development to Release?

目前,我们使用默认的合并WIZZARD。但是它有一个很大的限制 - 它不能由用户进行筛选。所以,我想建立一个应用程序,将拉动所有未合并的变更从开发到发布,并允许我用户过滤这些变更集。

Currently we use the default Merge Wizzard. However it has one big limitation - it cannot filter by user. So I was thinking of building an app that will pull all unmerged changesets from Development to Release and allow me to filter those changesets by user.

推荐答案

您可以写一个小控制台应用程序是这样的:

You could write a small console app that goes like this:

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace UnmergedChangesets
{
    class Program
    {
        static void Main(string[] args)
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://myserver:8080/collection"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));
            MergeCandidate[] mergeCandidates = vcs.GetMergeCandidates("$/Development", "$/Release", RecursionType.Full);
        }
    }
}

这样你进入 mergeCandidates 被遗漏在发布分公司所有的变更。 如果您想进一步过滤某个用户可以用类似的东西做到这一点:

This way you get into mergeCandidates all changesets that are missing in your Release branch. If you want to further filter for a certain user you can do this with something like that:

foreach (var mergeCandidate in mergeCandidates)
{
  if(mergeCandidate.Changeset.Owner == @"DOMAIN\ChuckNorris")
  {
    //This is an unmerged changeset commited by Chuck 
  }
}