TFS SDK启动三路合并

时间:2017-10-27 14:56:37

标签: c# tfs

TFS SDK中有一个ThreeWayMerge类。 Run有一个功能。有一个property可以在外部工具中运行合并。但是,当我运行这样的代码来解决冲突时,一切都没有发生。没错。没有结果。输出临时文件被删除。当我希望工具像Difference.VisualDiffItems一样启动时。我错了我的期望还是做错了什么?

public void Merge(string sourceFile)
    {
        string tempBase = Path.GetTempFileName();
        string tempLatest = Path.GetTempFileName();
        string tempModified = Path.GetTempFileName();
        string tempOutput = Path.GetTempFileName();

        Conflict[] conflicts = workSpace.QueryConflicts(new string[] { sourceFile }, false);
        Conflict cnf = conflicts[0];
        cnf.DownloadBaseFile(tempBase);
        //cnf.DownloadYourFile(tempModified);
        File.Copy(cnf.LocalPath, tempModified,true);
        cnf.DownloadTheirFile(tempLatest);

        int baseCodePage = FileType.Detect(tempBase, null);
        int latestCodePage = FileType.Detect(tempLatest, null);
        int modifiedCodePage = FileType.Detect(tempModified, null);

        ThreeWayMerge threeWayMerge = new ThreeWayMerge();
        threeWayMerge.UseExternalMergeTool = true;
        threeWayMerge.UseExternalAutomergeTool = true;
        threeWayMerge.VersionControlServerGuid = VCS.ServerGuid;
        threeWayMerge.LatestFileName = tempLatest;
        threeWayMerge.LatestFileEncoding = Encoding.GetEncoding(latestCodePage);
        threeWayMerge.ModifiedFileName = tempModified;
        Encoding modifiedEncoding = Encoding.GetEncoding(modifiedCodePage);
        threeWayMerge.ModifiedFileEncoding = modifiedEncoding;
        threeWayMerge.OriginalFileName = tempBase;
        threeWayMerge.OriginalFileEncoding = Encoding.GetEncoding(baseCodePage);
        threeWayMerge.MergedFileName = tempOutput;
        threeWayMerge.MergedFileEncoding = modifiedEncoding;
        if (threeWayMerge.Run())
        {

            Console.WriteLine("Something");
        }
    }

0 个答案:

没有答案