TFS-SDK:合并不起作用

标签 tfs merge tfs-sdk

作为更大实现的一部分,我正在尝试使用 TFS-SDK 实现我的源代码管理分支/文件夹的合并操作。我正在针对 TFS2010 安装工作。我所拥有的是:

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看起来像这样:enter image description here这几乎说明什么都没有发生。然而,如果我尝试在 IDE 中合并,我会得到几个合并候选者。如果我执行以下操作,也可以看到相同的合并候选者:
var mergeCandidates = versionControl.GetMergeCandidates(fromPath, toPath,RecursionType.Full).ToList();

我都失败了 fromPath/toPath是分支和文件夹 - 即使是单个文件。我能找到的唯一资源是 this一个,这没有帮助......

最佳答案

Shai Raiten的blog-post来救援!

这失败了:

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:合并不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9396738/

相关文章:

c# - 如何从 TFS API 中的产品待办列表项中检索子任务列表?

tfs - 查找TFS中所有锁定的文件

testing - 测试第一次失败是什么时候?

tfs - Azure cli Azure Devops 错误 : The user '' is not authorized to access this resource

version-control - 如何让 TFS 2013 检测文件系统中删除的文件?

c# - 通过 C# SqlCommand 执行合并语句不起作用

pandas - 使用 Pandas ,如何在变量索引上连接两个表?

r - 合并数据集而不丢失数据

c# - WIQL : How to get the content of a field of a work item returned by a query

c# - Microsoft.TeamFoundation.VersionControl.Client 位置?