TFS-SDK:合并不起作用 [英] TFS-SDK: Merge doesn't work
问题描述
作为更大实现的一部分,我试图使用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'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屋!