How to get all unmerged changesets for a branch using TFS 2010 SDK?

坚强是说给别人听的谎言 提交于 2019-12-20 03:30:21

问题


Currently I have 2 branches - Development and Release.

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

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.


回答1:


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

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



回答2:


Take a look at codeproject if you the standard windows doesn't fit your needs.

Somebody has done such a type of application so you can look how it works

TFS 2010 SDK: Smart Merge - Programmatically Create your own Merge Tool

Edit

I forgot, i work with this project template for VS2010

Visual Studio 2010 Project Template for TFS Utilities



来源:https://stackoverflow.com/questions/8201227/how-to-get-all-unmerged-changesets-for-a-branch-using-tfs-2010-sdk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!