TFS-SDK:合并不起作用 [英] TFS-SDK: Merge doesn't work

查看:109
本文介绍了TFS-SDK:合并不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为更大实现的一部分,我试图使用TFS-SDK实现源代码控制分支/文件夹的合并操作.我正在安装TFS2010.
我的意思是:

As part of a bigger implementation, I'm trying to implement a merge operation of my source control branches/folders using TFS-SDK. I'm working against a TFS2010 installation.
What I have is this:

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

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

            const string fromPath = "$/TeamProject/SourceDir";
            const string toPath = "$/TeamProject/TargetDir";

            Workspace myWorkspace = versionControl.GetWorkspace("WorkspaceName", "WorkspaceOwner");
            GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, VersionSpec.Latest, VersionSpec.Latest,
                                                    LockLevel.None, RecursionType.Full, MergeOptionsEx.None);
        }
    }
}

我相信我可以正确访问myWorkspace,但是getStatus看起来像这样:


几乎说什么也没发生.

如果我尝试在IDE中进行合并,则会得到多个合并候选对象.
如果我执行以下操作,也可以看到相同的合并候选者:

I'm convinced that I get proper access to myWorkspace, yet the getStatus looks like this:


That pretty much says that nothing has happened.

Yet if I try to merge in the IDE, I get several merge candidates.
The same merge candidates are also visible if I do a:

var mergeCandidates = versionControl.GetMergeCandidates(fromPath, toPath,RecursionType.Full).ToList();

我失败了,因为fromPath/toPath都是分支和文件夹-甚至只有单个文件.
我能找到的唯一资源是

I failed with both fromPath/toPath being branches and folders - even with single file.
The only resource out there I could find was this one, which didn't help...

推荐答案

Shai Raiten的

Shai Raiten's blog-post to the rescue!

此操作失败:

This failed:

GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, VersionSpec.Latest, VersionSpec.Latest,
                                                    LockLevel.None, RecursionType.Full, MergeOptionsEx.None);

成功:

GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, null, null, LockLevel.None, RecursionType.Full, MergeOptionsEx.None);

这篇关于TFS-SDK:合并不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆