public abstract Add ( FilePath path, bool recurse, IProgressMonitor monitor ) : void | ||
path | FilePath | |
recurse | bool | |
monitor | IProgressMonitor | |
return | void |
protected override void OnAdd(FilePath[] paths, bool recurse, IProgressMonitor monitor) { foreach (FilePath path in paths) { if (IsVersioned(path) && File.Exists(path) && !Directory.Exists(path)) { if (rootPath.IsNull) { throw new UserException(GettextCatalog.GetString("Project publishing failed. There is a stale .svn folder in the path '{0}'", path.ParentDirectory)); } VersionInfo srcInfo = GetVersionInfo(path, VersionInfoQueryFlags.IgnoreCache); if (srcInfo.HasLocalChange(VersionStatus.ScheduledDelete)) { // It is a file that was deleted. It can be restored now since it's going // to be added again. // First of all, make a copy of the file string tmp = Path.GetTempFileName(); File.Copy(path, tmp, true); // Now revert the status of the file Revert(path, false, monitor); // Copy the file over the old one and clean up File.Copy(tmp, path, true); File.Delete(tmp); } } else { if (!IsVersioned(path.ParentDirectory)) { // The file/folder belongs to an unversioned folder. We can add it by versioning the parent // folders up to the root of the repository if (!path.IsChildPathOf(rootPath)) { throw new InvalidOperationException("File outside the repository directory"); } List <FilePath> dirChain = new List <FilePath> (); FilePath parentDir = path.CanonicalPath; do { parentDir = parentDir.ParentDirectory; if (Directory.Exists(SubversionVersionControl.GetDirectoryDotSvn(parentDir))) { break; } dirChain.Add(parentDir); }while (parentDir != rootPath); // Found all parent unversioned dirs. Versin them now. dirChain.Reverse(); FileUpdateEventArgs args = new FileUpdateEventArgs(); foreach (var d in dirChain) { Svn.Add(d, false, monitor); args.Add(new FileUpdateEventInfo(this, dirChain [0], true)); } VersionControlService.NotifyFileStatusChanged(args); } Svn.Add(path, recurse, monitor); } } }