private static WorkingDirectory DeriveWorkingDirectory () { DirectoryInfo currDir = new DirectoryInfo(Environment.CurrentDirectory); LOGGER.Info(string.Format("Repository is null, " + "attempting to derive from current directory: {0}.", currDir.FullName)); Manager manager = new Manager(currDir); Repository repository = manager.FetchRepository(currDir.FullName); Root root = manager.FetchRoot(currDir.FullName); CvsRoot cvsRoot = new CvsRoot(root.FileContents); return new WorkingDirectory(cvsRoot, Environment.CurrentDirectory, repository.ModuleName); }
/// <summary> /// Setup the list of files to be a folder object for the cvs /// library to process. /// </summary> /// <param name="filesAdded">An array filenames that are to be added /// to the cvs repository.</param> private Folders GetFoldersToAdd (ICollection filesAdded) { Folders folders = new Folders(); Manager manager = new Manager(Environment.CurrentDirectory); LOGGER.Debug("Number of files copied=[" + filesAdded.Count + "]"); foreach (String file in filesAdded) { Folder folder; if (!folders.Contains(Path.GetDirectoryName(file))) { folder = new Folder(); LOGGER.Debug("file=[" + file + "]"); LOGGER.Debug("file path=[" + Path.GetDirectoryName(file) + "]"); folder.Repository = manager.FetchRepository(Path.GetDirectoryName(file)); folder.Root = manager.FetchRoot(Path.GetDirectoryName(file)); folder.Tag = manager.FetchTag(Path.GetDirectoryName(file)); folders.Add(Path.GetDirectoryName(file), folder); } else { folder = folders[Path.GetDirectoryName(file)]; } if (!folder.Entries.Contains(file)) { Entry entry = Entry.CreateEntry(new FileInfo(file)); folder.Entries.Add (file, entry); } else { folder.Entries[file] = Entry.CreateEntry(new FileInfo(file)); } } return folders; }
/// <summary> /// Create the command object that will be used to act on the repository. /// </summary> /// <returns>The command object that will be used to act on the /// repository.</returns> /// <exception cref="Exception">TODO: Make a more specific exception</exception> /// <exception cref="NotImplementedException">If the command argument /// is not implemented currently. TODO: Implement the argument.</exception> public override ICommand CreateCommand () { ICSharpCode.SharpCvsLib.Commands.RemoveCommand removeCommand; this.ParseOptions(this.unparsedOptions); try { String currentDirectory = Environment.CurrentDirectory; Entry removeEntry; // Open the Repository file in the CVS directory Manager manager = new Manager(currentDirectory); Repository repository = manager.FetchRepository(currentDirectory); removeEntry = manager.FetchEntry(currentDirectory, fileNames ); // If this fails error out and state the user // is not in a CVS repository directory tree. CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot, currentDirectory, repository.FileContents); // Create new RemoveCommand object removeCommand = new ICSharpCode.SharpCvsLib.Commands.RemoveCommand( this.CurrentWorkingDirectory, currentDirectory, removeEntry); } catch (Exception e) { LOGGER.Error (e); throw e; } return removeCommand; }
/// <summary> /// Create the command object that will be used to act on the repository. /// </summary> /// <returns>The command object that will be used to act on the /// repository.</returns> /// <exception cref="Exception">TODO: Make a more specific exception</exception> /// <exception cref="NotImplementedException">If the command argument /// is not implemented currently. TODO: Implement the argument.</exception> public override ICommand CreateCommand () { ICSharpCode.SharpCvsLib.Commands.AddCommand addCommand; this.ParseOptions(this.unparsedOptions); try { // Open the Repository file in the CVS directory Manager manager = new Manager(Environment.CurrentDirectory); Repository repository = manager.FetchRepository(Environment.CurrentDirectory); // If this fails error out and state the user // is not in a CVS repository directory tree. CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot, Environment.CurrentDirectory, repository.FileContents); CurrentWorkingDirectory.OverrideDirectory = Environment.CurrentDirectory; // If fileNames has a wild card (*) like '*.txt' // Create new AddCommand object addCommand = new ICSharpCode.SharpCvsLib.Commands.AddCommand( this.CurrentWorkingDirectory); String[] files = Directory.GetFiles(Environment.CurrentDirectory, fileNames); ArrayList copiedFiles = new ArrayList (); foreach (String file in files) { LOGGER.Debug("file=[" + file + "]"); // Remove the .txt when everything works, giving me bugs... String fullPath = Path.Combine(Environment.CurrentDirectory, file); copiedFiles.Add(fullPath); } addCommand.Folders = GetFoldersToAdd(copiedFiles); } catch (Exception e) { LOGGER.Error (e); throw e; } return addCommand; }
/// <summary> /// Create the command object that will be used to act on the repository. /// </summary> /// <returns>The command object that will be used to act on the /// repository.</returns> /// <exception cref="Exception">TODO: Make a more specific exception</exception> /// <exception cref="NotImplementedException">If the command argument /// is not implemented currently. TODO: Implement the argument.</exception> public override ICommand CreateCommand () { ICSharpCode.SharpCvsLib.Commands.CommitCommand2 commitCommand; try { this.ParseOptions(this.unparsedOptions); string cvsFolder = Path.Combine(Environment.CurrentDirectory, "CVS"); // set properties before creation of CommitCommand2 // Open the Repository file in the CVS directory Manager manager = new Manager(cvsFolder); Repository repository = null; Root root = null; try { repository = manager.FetchRepository(cvsFolder); } catch (CvsFileNotFoundException e) { ConsoleMain.ExitProgram("Not a valid cvs repository.", e); } try { root = manager.FetchRoot(cvsFolder); if (null == this.cvsRoot) { this.cvsRoot = new CvsRoot(root.FileContents); } } catch (CvsFileNotFoundException e) { ConsoleMain.ExitProgram("Not a valid cvs repository.", e); } // If this fails error out and the user // is not in a CVS repository directory tree. CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot, cvsFolder, repository.FileContents); if (revision != null) { this.CurrentWorkingDirectory.Revision = revision; } ArrayList files = new ArrayList(); if (fileNames == null || fileNames == string.Empty) { this.GetFilesRecursive((new DirectoryInfo(cvsFolder)).Parent, files); } else { DirectoryInfo cvsFolderInfo = new DirectoryInfo(cvsFolder); files = new ArrayList(cvsFolderInfo.GetFiles(fileNames)); } CurrentWorkingDirectory.Folders = GetFoldersToCommit(files); // Create new CommitCommand2 object commitCommand = new ICSharpCode.SharpCvsLib.Commands.CommitCommand2( this.CurrentWorkingDirectory ); // set public properties on the commit command if (message != null) { commitCommand.LogMessage = message; } return commitCommand; } catch (CvsFileNotFoundException e) { ConsoleMain.ExitProgram(string.Format("No CVS folder found in path {0}", Environment.CurrentDirectory), e); return null; } catch (Exception e) { LOGGER.Error (e); throw e; } }