/// <summary> /// 'Pends' a branch of a file that was previously checked-in and then checks /// that branch into the repository. /// </summary> /// <param name="workspace">Version control workspace to use when /// branching the folder and file.</param> /// <param name="newFilename">Full path to the file to branch</param> /// <exception cref="VersionControlException">If there's a problem performing /// the branch operation.</exception> private static void BranchFile(Workspace workspace, String newFilename) { Debug.Assert(workspace != null); Debug.Assert(!String.IsNullOrEmpty(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"); Console.WriteLine("Branched {0} to {1} in changeset {2}", newFilename, branchedFilename, changesetForBranch); }