Ejemplo n.º 1
0
        /// <summary>
        ///     Fetch the cvs file information to update.
        /// </summary>
        /// <param name="directory">The directory to fetch the files information
        ///        from.</param>
        /// <returns>A collection of folders that contain the cvs entries for
        ///       each directory.</returns>
        public Folder[] FetchFilesToUpdate (String directory) {
            Folders folders = new Folders ();
            Folder folder = new Folder ();
            DirectoryInfo dir = new DirectoryInfo(directory);
            try {
                folder.Repository = Repository.Load(dir);
                folder.Entries = Entries.Load(dir);

                folders.Add (directory, folder);
            } catch (CvsFileNotFoundException) {
                // File not found, this is normal recursing through the tree.
            }

            if (dir.Name != "CVS") {
                this.FetchFilesToUpdateRecursive (folders, dir);
            } else if (this.IsInSandbox(dir.Parent.FullName) &&
                dir.Parent.Name != "CVS") {
                this.FetchFilesToUpdateRecursive (folders, dir.Parent);
            }

            return (Folder[])(new ArrayList(folders.Values)).ToArray (typeof (Folder));
        }
Ejemplo n.º 2
0
        private void FetchFilesToUpdateRecursive (Folders folders,
                DirectoryInfo dir) {

            foreach (DirectoryInfo subDir in dir.GetDirectories()) {
                if (!PathTranslator.IsCvsDir(subDir)) {
                    Folder folder = new Folder ();

                    try {
                        folder.Repository = Repository.Load(dir);
                        Entries colEntries = Entries.Load(dir);

                        foreach (DictionaryEntry dicEntry in colEntries) {
                            Entry entry = (Entry)dicEntry.Value;
                            folder.Entries.Add (entry.FullPath, entry);
                        }
                        folders.Add (subDir.FullName, folder);
                    } catch (CvsFileNotFoundException) {
                        //File not found, this is normal recursing through the tree.
                    }
                    this.FetchFilesToUpdateRecursive (folders, subDir);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populates a Folders collection for the files that have been specified
        ///     in the file list.
        /// </summary>
        /// <param name="files">Files on the filesystem that are under cvs
        ///     control.</param>
        /// <returns>A collection of Folders object that encapsulates the cvs 
        ///     repository information for the collection of files specified.</returns>
        public Folders GetFolders(ICollection files) {
            Folders folders = new Folders();
            foreach (String file in files) {
                Folder folder;
                if (!folders.Contains (Path.GetDirectoryName(file))) {
                    folder = this.CreateFolder(file);
                    folders.Add (Path.GetDirectoryName(file), folder);
                } else {
                    folder = folders[Path.GetDirectoryName(file)];
                }

                // If the entry file is not already contained in the entries 
                //      collection then add it.
                if (!folder.Entries.Contains (Path.GetFullPath(file))) {
                    Entry entry;
                    try {
                        entry = this.FetchEntry (file);
                        folder.Entries.Add (entry.FullPath, entry);
                    } catch (EntryNotFoundException e) {
                        LOGGER.Debug(@"Entry not found, probably does not exist, 
                            or is new file.  Wait for add to add it.", e);
                    }
                }
            }

            return folders;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Fetch all files in the cvs folder.
        /// </summary>
        /// <param name="directory"></param>
        /// <returns></returns>
        public Folders FetchFilesToAdd (string directory) {
            DirectoryInfo dirInfo = new DirectoryInfo(directory);
            ArrayList directories = new ArrayList();

            if (!dirInfo.Exists) {
                throw new ArgumentException(string.Format("Directory {0} does not exist.",
                    dirInfo.FullName));
            }

            directories = this.FetchDirectoriesRecursive(dirInfo);
            Folders folders = new Folders();

            foreach (DirectoryInfo dir in directories) {
                Folder folder = new Folder();
                foreach (FileInfo file in dir.GetFiles()) {
                    Entry entry = Entry.CreateEntry(file);
                    folder.Entries.Add(entry.FullPath, entry);
                }
                folders.Add(dir.FullName, folder);
            }
            return folders;
        }
Ejemplo n.º 5
0
 public LogCommand(WorkingDirectory workingDirectory, Folders folders) {
     this.workingDirectory = workingDirectory;
     this.folders = folders;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Parse the command line options/ arguments and populate the command
        ///     object with the arguments.
        /// </summary>
        /// <param name="arguments">A string value that holds the command
        ///     line options the user has selected.</param>
        private void ParseOptions (string[] arguments) {
            string singleOptions = "lRhtNbT";
            string options = string.Empty;
            int i = 0;
            // get rest of arguments which is options on the checkout command.
            while (arguments.Length > i && arguments[i].Trim().IndexOf("-") == 0){
                // Get options with second parameters?
                string arg = arguments[i].Trim();
                if (arg.IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0){
                    switch (arg) {
                        case "-l":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-R":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-h":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-t":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-N":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-b":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-T":
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        default:
                            break;
                    }
                } else {
                    switch (arg) {
                        case "-r":
                            this.revision = arguments[++i];
                            break;
                        case "-d":
                            this.date = Convert.ToDateTime(arguments[++i]);
                            break;
                        case "-s":
                            i++;
                            throw new NotImplementedException(string.Format("Argument not implemented {0}.", arg));
                        case "-w":
                            i++;
                            break;
                        default:
                            break;
                    }
                }
                i++;
            }

            // add the current folder by default
            this.folders = new Folders();
            folders.Add(new Folder(new DirectoryInfo(Directory.GetCurrentDirectory())));
            // parse out the file information, skip the command name
            int fileIndex = 0;
            while (arguments.Length > fileIndex && arguments[fileIndex].IndexOf("-") == -1) {
                string file = arguments[fileIndex];
                FileInfo fileInfo = null;
                if (Path.IsPathRooted(file)) {
                    fileInfo = new FileInfo(file);
                } else {
                    fileInfo = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), file));
                }

                if (!folders.Contains(fileInfo.DirectoryName)) {
                    folders.Add(new Folder(new DirectoryInfo(fileInfo.DirectoryName)));
                }
                Folder folder = folders[fileInfo.DirectoryName];
                Entry entry = Entries.Load(new DirectoryInfo(fileInfo.DirectoryName))[fileInfo.FullName];
                folder.Entries.Add(entry);

                fileIndex++;
            }
        }
 private Folders GetCurrentDirectory(DirectoryInfo directory) {
     Folders folders = new Folders();
     Folder folder = new Folder(new DirectoryInfo(Directory.GetCurrentDirectory()));
     folder.Entries = Entries.Load(folder.Path);
     folders.Add(folder);
     return folders;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="workingdirectory"></param>
 /// <param name="directory"></param>
 /// <param name="entry"></param>
 public StatusCommand(WorkingDirectory workingdirectory, 
     string directory, Entry entry){
     this._workingdirectory    = workingdirectory;
     this.directory = directory;
     this.entry = entry;
     if (null == this.Folders) {
         this._folders = new Folders();
         Folder folder = new Folder();
         folder.Entries.Add(entry);
         this._folders.Add(folder);
     }
 }
Ejemplo n.º 9
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;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Clear folders collection.
 /// </summary>
 public void Clear()
 {
     folders = new Folders();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Setup the list of files to be a folder object for the cvs
 ///     library to process.
 /// </summary>
 /// <param name="filesCommitted">An array filenames that are to be committed
 ///     to the cvs repository.</param>
 private Folders GetFoldersToCommit (ICollection filesCommitted) {
     Folders folders = new Folders();
     Manager manager = new Manager(Environment.CurrentDirectory);
     foreach (FileInfo file in filesCommitted) {
         Folder folder;
         if (!folders.Contains(file.DirectoryName)) {
             folder = new Folder();
             DirectoryInfo cvsFolder = 
                 new DirectoryInfo(Path.Combine(file.DirectoryName, "CVS"));
             folder.Repository = Repository.Load(cvsFolder);
             folder.Root = Root.Load(cvsFolder);
             try {
                 folder.Tag = Tag.Load(cvsFolder);
             } catch (CvsFileNotFoundException) {
                 // ignore, tag missing normal
             }
             folder.Entries = Entries.Load(cvsFolder);
             folders.Add(file.DirectoryName, folder);
         } 
     }
     return folders;
 }