【发布时间】:2014-12-03 15:34:59
【问题描述】:
我正在尝试使用 API 创建一个新分支,并且同时使用了 PendBranch() 和 CreateBranch()。 CreateBranch() 的问题是它立即提交,我希望能够在签入分支时添加 cmets。所以,我所做的如下所示。
基本上,我从我的 Windows 应用程序中获取所有信息,例如要映射的服务器项和本地项,以及分支的源和目标。
不知何故,当我看到源代码管理资源管理器时,它仍然显示 “未映射”,即使我在创建工作区后给出了:workspace.Get() 和 workspace.Map(serverItem,localItem)
有人能解释一下吗?
public void CreateNewBranch(string server,string serverItem,string localItem,string sourceBranch, string targetBranch)
{
int changeSetNumber = 0;
// Get a reference to Team Foundation Server and Source Control.
tfs = GetTFS(server);
// Create a new workspace for the currently authenticated user.
workspace = tfvc.CreateWorkspace("Example Workspace", tfvc.AuthenticatedUser);
}
// Create a mapping to the project.
try
{
workspace.Map(serverItem, localItem);
// Get the latest source files from the repository.
//workspace.Get();
// Perform a pending Branch operation.
workspace.PendBranch(sourceBranch, targetBranch, VersionSpec.Latest);
// Get a list of all the Pending Changes.
PendingChange[] pendingChanges = workspace.GetPendingChanges();
if (pendingChanges.Length > 0)
{
changeSetNumber = workspace.CheckIn(pendingChanges, "Comment:Branch Created");
MessageBox.Show("Checked in changeset # " + changeSetNumber);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
// Cleanup the workspace.
workspace.Delete();
}
}
【问题讨论】:
标签: api version-control tfs branch new-operator