2

APIを使用して新しいブランチを作成しようとしていますが、との両方を使用していPendBranch()ますCreateBranch()。問題CreateBranch()は、すぐにコミットし、ブランチがチェックインされたときにコメントを追加できるようにすることです。そこで、私が行ったことを以下に示します。

基本的に、マップするサーバーアイテムやローカルアイテムなどのすべての情報と、ブランチのソースとターゲットを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();
        }
    }
4

1 に答える 1

5

TFSチェンジセットでは、コメントは実際に編集可能です。したがって、VS2008 /TFS2008SP1で導入されたCreateBranchメソッドを利用する次のようなものを試すことができます。

public void CreateBranchWithComment(
    string serverUrl, 
    string sourcePath, 
    string targetPath, 
    string comment)
{
    TeamFoundationServer tfs = new TeamFoundationServer(serverUrl);
    VersionControlServer vcServer = 
        (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

    int changesetId = vcServer.CreateBranch(
        sourcePath, 
        targetPath, 
        VersionSpec.Latest);

    Changeset changeset = vcServer.GetChangeset(changesetId);
    changeset.Comment = comment;
    changeset.Update();

}
于 2009-10-13T10:33:43.417 に答える