private void FillInMissingComments( VaultTxDetailHistoryItem [] changes, string changeSetComment ) { foreach( VaultTxDetailHistoryItem change in changes ) { if( change.Comment == null || change.Comment == string.Empty ) { change.Comment = changeSetComment; } } }
private void vaultGetFile(string repoPath, VaultTxDetailHistoryItem txdetailitem) { // Allow exception to percolate up. Presume its due to a file missing from the latest Version // thats in this Version. That is, this file is later deleted, moved or renamed. //apply version to the repo folder if (Verbose) Console.WriteLine("get {0} version {1}", txdetailitem.ItemPath1, txdetailitem.Version); vaultProcessCommandGetVersion(txdetailitem.ItemPath1, txdetailitem.Version, false); if (Verbose) Console.WriteLine("get {0} version {1} SUCCESS!", txdetailitem.ItemPath1, txdetailitem.Version); //now process deletions, moves, and renames (due to vault bug) var allowedRequests = new int[] { VaultRequestType.Delete, VaultRequestType.Move, VaultRequestType.Rename }; if (allowedRequests.Contains(txdetailitem.RequestType)) { //delete file //check if it is within current branch if (txdetailitem.ItemPath1.StartsWith(repoPath, StringComparison.CurrentCultureIgnoreCase)) { var pathToDelete = Path.Combine(this.WorkingFolder, txdetailitem.ItemPath1.Substring(repoPath.Length + 1)); if (Verbose) Console.WriteLine("delete {0} => {1}", txdetailitem.ItemPath1, pathToDelete); if (File.Exists(pathToDelete)) File.Delete(pathToDelete); if (Directory.Exists(pathToDelete)) { Directory.Delete(pathToDelete, true); // Ensure its really deleted so iteration of directories by caller does not cause dir not exist exception Thread.Sleep(500); } } } }
public void ProcessFileItem( String vaultRepoPath, String workingFolder, VaultTxDetailHistoryItem txdetailitem, bool moveFiles ) { // Convert the Vault path to a file system path String ItemPath1 = String.Copy(txdetailitem.ItemPath1); String ItemPath2 = String.Copy(txdetailitem.ItemPath2); // Ensure the files are withing the folder we are working with. // If the source path is outside the current branch, throw an exception and let vault handle the processing because // we do not have the correct state of files outside the current branch. // If the target path is outside, ignore a file copy and delete a file move. // E.g. A Share can be shared outside of the branch we are working with if (Verbose) Console.WriteLine("Processing {0} to {1}. MoveFiles = {2})", ItemPath1, ItemPath2, moveFiles); bool ItemPath1WithinCurrentBranch = ItemPath1.StartsWith(vaultRepoPath, true, System.Globalization.CultureInfo.CurrentCulture); bool ItemPath2WithinCurrentBranch = ItemPath2.StartsWith(vaultRepoPath, true, System.Globalization.CultureInfo.CurrentCulture); if (!ItemPath1WithinCurrentBranch) { if (Verbose) Console.WriteLine(" Source file is outside of working folder. Error"); throw new FileNotFoundException( "Source file is outside the current branch: " + ItemPath1); } // Don't copy files outside of the branch if (!moveFiles && !ItemPath2WithinCurrentBranch) { if (Verbose) Console.WriteLine(" Ignoring target file outside of working folder"); return; } ItemPath1 = ItemPath1.Replace(vaultRepoPath, workingFolder, StringComparison.CurrentCultureIgnoreCase); ItemPath1 = ItemPath1.Replace('/', '\\'); ItemPath2 = ItemPath2.Replace(vaultRepoPath, workingFolder, StringComparison.CurrentCultureIgnoreCase); ItemPath2 = ItemPath2.Replace('/', '\\'); if (File.Exists(ItemPath1)) { string directory2 = Path.GetDirectoryName(ItemPath2); if (!Directory.Exists(directory2)) { Directory.CreateDirectory(directory2); } if (ItemPath2WithinCurrentBranch && File.Exists(ItemPath2)) { if (Verbose) Console.WriteLine(" Deleting {0}", ItemPath2 ); File.Delete(ItemPath2); } if (moveFiles) { // If target is outside of current branch, just delete the source file if (!ItemPath2WithinCurrentBranch) { if (Verbose) Console.WriteLine(" Deleting {0}", ItemPath1); File.Delete(ItemPath1); } else { if (Verbose) Console.WriteLine(" Moving {0}", ItemPath2); File.Move(ItemPath1, ItemPath2); } } else { if (Verbose) Console.WriteLine(" Copying {0} to [1]", ItemPath1, ItemPath2); File.Copy(ItemPath1, ItemPath2); } } else if (Directory.Exists(ItemPath1)) { if (moveFiles) { // If target is outside of current branch, just delete the source directory if (!ItemPath2WithinCurrentBranch) { Directory.Delete(ItemPath1); } else { Directory.Move(ItemPath1, ItemPath2); } } else { DirectoryCopy(ItemPath1, ItemPath2, true); } } }