Exemplo n.º 1
0
 /// <summary>
 /// Load the root file.
 /// </summary>
 /// <param name="rootFile"></param>
 /// <returns></returns>
 public static Root Load (FileInfo rootFile) {
     if (rootFile.Name != Root.FILE_NAME) {
         throw new ArgumentException(string.Format("Not a valid Root file, {0}",
             rootFile.FullName));
     }
     Manager manager = new Manager(rootFile.DirectoryName);
     return manager.FetchRoot(rootFile.DirectoryName);
 }
Exemplo n.º 2
0
 /// <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;
 }
 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>
        /// 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;
            }
        }