TFS二次開發08——分支(Branch)和合並(Merge)

一:建立分支  服務器

private static void BranchFile(Workspace workspace, String newFilename)
{
  String branchedFilename = Path.Combine(Path.GetDirectoryName(newFilename),
  Path.GetFileNameWithoutExtension(newFilename)) + "-branch" + Path.GetExtension(newFilename);
  workspace.PendBranch(newFilename, branchedFilename, VersionSpec.Latest, LockLevel.Checkin, true);
  var pendingChanges = workspace.GetPendingChanges();
  int changesetForBranch = workspace.CheckIn(pendingChanges, "Branched file");     
}

二:合併分支spa

private void Merge(Workspace workspace,string source,string target)
{
    GetStatus status = workspace.Merge(source,
                target,
                null,
                null,
                LockLevel.None,
                RecursionType.Full,
                MergeOptions.None);
    
   status.NumConflicts.ToString();//衝突數量
   status.NumFailures.ToString(); //失敗數量
   status.NumOperations.ToString();//服務器端的操做數量
   status.NumWarnings.ToString();  //警告數量
    
}
相關文章
相關標籤/搜索