public override void DeleteDirectories(FilePath[] paths, bool force, IProgressMonitor monitor) { foreach (string path in paths) { if (IsVersioned(path)) { Svn.Delete(path, force, monitor); } else { Directory.Delete(path, true); } } }
protected override async Task OnDeleteDirectoriesAsync(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal) { foreach (string path in localPaths) { if (!keepLocal) { FileService.AssertCanDeleteDirectory(path, RootPath); } if (await IsVersionedAsync(path, monitor.CancellationToken).ConfigureAwait(false)) { string newPath = String.Empty; if (keepLocal) { newPath = FileService.CreateTempDirectory(); FileService.CopyDirectory(path, newPath); } try { Svn.Delete(path, force, monitor); } finally { if (keepLocal) { FileService.MoveDirectory(newPath, path); } } } else { if (keepLocal) { foreach (var info in await GetDirectoryVersionInfoAsync(path, false, true, monitor.CancellationToken).ConfigureAwait(false)) { if (info != null && info.HasLocalChange(VersionStatus.ScheduledAdd)) { // Revert the add command await RevertAsync(path, false, monitor).ConfigureAwait(false); } } } else { Directory.Delete(path, true); } } } }
public override void DeleteFiles(FilePath[] paths, bool force, IProgressMonitor monitor) { foreach (string path in paths) { if (IsVersioned(path)) { Svn.Delete(path, force, monitor); } else { VersionInfo srcInfo = GetVersionInfo(path, false); if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd)) { // Revert the add command Revert(path, false, monitor); } File.Delete(path); } } }
protected override void OnDeleteDirectories(FilePath[] localPaths, bool force, IProgressMonitor monitor, bool keepLocal) { foreach (string path in localPaths) { if (IsVersioned(path)) { string newPath = String.Empty; if (keepLocal) { newPath = FileService.CreateTempDirectory(); FileService.CopyDirectory(path, newPath); } try { Svn.Delete(path, force, monitor); } finally { if (keepLocal) { FileService.MoveDirectory(newPath, path); } } } else { if (keepLocal) { foreach (var info in GetDirectoryVersionInfo(path, false, true)) { if (info != null && info.HasLocalChange(VersionStatus.ScheduledAdd)) { // Revert the add command Revert(path, false, monitor); } } } else { Directory.Delete(path, true); } } } }
protected override async Task OnDeleteFilesAsync(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal) { foreach (string path in localPaths) { if (await IsVersionedAsync(path, monitor.CancellationToken).ConfigureAwait(false)) { string newPath = String.Empty; if (keepLocal) { newPath = Path.GetTempFileName(); File.Copy(path, newPath, true); } try { Svn.Delete(path, force, monitor); } finally { if (keepLocal) { File.Move(newPath, path); } } } else { if (keepLocal) { VersionInfo srcInfo = await GetVersionInfoAsync(path, VersionInfoQueryFlags.IgnoreCache); if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd)) { // Revert the add command await RevertAsync(path, false, monitor).ConfigureAwait(false); } } else { File.Delete(path); } } } }
protected override void OnDeleteFiles(FilePath[] localPaths, bool force, IProgressMonitor monitor, bool keepLocal) { foreach (string path in localPaths) { if (IsVersioned(path)) { string newPath = String.Empty; if (keepLocal) { newPath = Path.GetTempFileName(); File.Copy(path, newPath, true); } try { Svn.Delete(path, force, monitor); } finally { if (keepLocal) { File.Move(newPath, path); } } } else { if (keepLocal) { VersionInfo srcInfo = GetVersionInfo(path, VersionInfoQueryFlags.IgnoreCache); if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd)) { // Revert the add command Revert(path, false, monitor); } } else { File.Delete(path); } } } }
public override void MoveDirectory(FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor) { if (IsVersioned(destPath)) { VersionInfo vinfo = GetVersionInfo(destPath, false); if (!vinfo.HasLocalChange(VersionStatus.ScheduledDelete) && Directory.Exists(destPath)) { throw new InvalidOperationException("Cannot move directory. Destination directory already exist."); } srcPath = srcPath.FullPath; // The target directory does not exist, but it is versioned. It may be because // it is scheduled to delete, or maybe it has been physicaly deleted. In any // case we are going to replace the old directory by the new directory. // Revert the old directory, so we can see which files were there so // we can delete or replace them Revert(destPath, true, monitor); // Get the list of files in the directory to be replaced ArrayList oldFiles = new ArrayList(); GetDirectoryFiles(destPath, oldFiles); // Get the list of files to move ArrayList newFiles = new ArrayList(); GetDirectoryFiles(srcPath, newFiles); // Move all new files to the new destination Hashtable copiedFiles = new Hashtable(); Hashtable copiedFolders = new Hashtable(); foreach (string file in newFiles) { string src = Path.GetFullPath(file); string dst = Path.Combine(destPath, src.Substring(((string)srcPath).Length + 1)); if (File.Exists(dst)) { File.Delete(dst); } // Make sure the target directory exists string destDir = Path.GetDirectoryName(dst); if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } // If the source file is versioned, make sure the target directory // is also versioned. if (IsVersioned(src)) { MakeDirVersioned(destDir, monitor); } MoveFile(src, dst, true, monitor); copiedFiles [dst] = dst; string df = Path.GetDirectoryName(dst); copiedFolders [df] = df; } // Delete all old files which have not been replaced ArrayList foldersToDelete = new ArrayList(); foreach (string oldFile in oldFiles) { if (!copiedFiles.Contains(oldFile)) { DeleteFile(oldFile, true, monitor); string fd = Path.GetDirectoryName(oldFile); if (!copiedFolders.Contains(fd) && !foldersToDelete.Contains(fd)) { foldersToDelete.Add(fd); } } } // Delete old folders foreach (string folder in foldersToDelete) { Svn.Delete(folder, true, monitor); } // Delete the source directory DeleteDirectory(srcPath, true, monitor); } else { if (Directory.Exists(destPath)) { throw new InvalidOperationException("Cannot move directory. Destination directory already exist."); } VersionInfo srcInfo = GetVersionInfo(srcPath, false); if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd)) { // If the directory is scheduled to add, cancel it, move the directory, and schedule to add it again MakeDirVersioned(Path.GetDirectoryName(destPath), monitor); Revert(srcPath, true, monitor); base.MoveDirectory(srcPath, destPath, force, monitor); Add(destPath, true, monitor); } else { if (IsVersioned(srcPath)) { MakeDirVersioned(Path.GetDirectoryName(destPath), monitor); Svn.Move(srcPath, destPath, force, monitor); } else { base.MoveDirectory(srcPath, destPath, force, monitor); } } } }