TFS 2010 - merge changesets

感情迁移 提交于 2020-01-05 08:52:32

问题


In TFS 2010, the scenario is to merge the selected changesets via tf command line. Suppose there were 20 changesets which is to be merged from branch to main folder. I am using the tf command line to merge all the 20 changesets. If there is a conflict in any of the changeset, email should be triggered to the person who checked-in the changesets. Is there is anyway to send an email to the person who checkin the changeset?


回答1:


I think your only resort is to write an application that will take as input the sourceBranch and the targetBranch & will try to programmatically merge the latest of the one to the other. Then it 'll query for conflicts, find the Changeset they belong to and finally send the email to the Changeset owner.

The following bases heavily on the work by Eugene Zakhareyev found here:

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

namespace DetectConflicts
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFS:8080/tfs/{Collection}"));
            var versionControl = teamProjectCollection.GetService<VersionControlServer>();

            const string sourceBranch = "$/PathToFROMBranch";
            const string targetBranch = "$/PathToTOBranch";

            Workspace myWorkspace = versionControl.GetWorkspace("WorkspaceName", "{DOMAIN}\\YourName");
            GetStatus getStatus = myWorkspace.Merge(sourceBranch,
                        targetBranch,
                        null,
                        null,
                        LockLevel.None,
                        RecursionType.Full,
                        MergeOptions.None);

            Conflict[] conflicts = myWorkspace.QueryConflicts(new[] {targetBranch}, true);
            foreach (var conflict in conflicts)
            {
                string owner = versionControl.GetChangeset(conflict.TheirVersion).Owner;
                //
                //send an email to "owner"
                //
                ...
            }
        }
    }
}


来源:https://stackoverflow.com/questions/8923084/tfs-2010-merge-changesets

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