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); } } }
private void SetDirectory (ICommandConnection connection, Folder folder) { String absoluteDir = connection.Repository.CvsRoot.CvsRepository + "/" + folder.Repository.FileContents; try { connection.SubmitRequest(new DirectoryRequest(".", absoluteDir)); } catch (Exception e) { String msg = "Exception while submitting directory request. " + "path=[" + folder.Repository.FileContents + "]"; LOGGER.Error (e); } }
/// <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; }
/// <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)); }
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; }
/// <summary> /// Creates a new folder that represents the directory name specified in /// the path string passed in. The folder is also populated with /// the following objects from the <code>CVS</code> directory: /// <ul> /// <li>Repository</li> /// <li>Root</li> /// <li>Tag</li> /// </ul> /// Entries are then populated for each file in the filesystem. /// </summary> /// <param name="path">A path that represents the new folder location /// on the filesystem.</param> /// <returns>A new folder object that contains the information stored in /// the cvs folder.</returns> private Folder CreateFolder (String path) { Folder newFolder = new Folder(); newFolder.Entries = new Entries (); newFolder.Repository = this.FetchRepository (Path.GetDirectoryName(path)); newFolder.Tag = this.FetchTag (Path.GetDirectoryName(path)); newFolder.Root = this.FetchRoot (Path.GetDirectoryName(path)); return newFolder; }
/// <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> /// 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); } }
/// <summary> /// Add the given folder to the collection. The folder key is the path to /// the folder on the filesystem. /// </summary> /// <param name="path">The path to the folder on the filesystem.</param> /// <param name="folder">The folder object to add to the collection.</param> public void Add(String path, Folder folder) { if (null == folder.Path) { folder.Path = new DirectoryInfo(path); } Dictionary.Add(path, folder); }
/// <summary> /// Add the folder to the folders collection. /// <br/> /// </summary> /// <param name="folder">The folder to add to the collection.</param> /// <exception cref="ArgumentException">If the Folder.Path value is null.</exception> public void Add(Folder folder) { if (null == folder.Path) { throw new ArgumentException("Folder.Path cannot be null."); } Dictionary.Add(folder.Path.FullName, folder); }
private void FetchFilesRecursive(ArrayList folders, string localDirectory) { String modulePath = localDirectory; Manager manager = new Manager(modulePath); Folder folder = new Folder (); folder.Repository = (Repository)manager.FetchSingle (modulePath, Factory.FileType.Repository); Entries entries1= manager.FetchEntries(Path.Combine(modulePath, Entry.FILE_NAME)); foreach (DictionaryEntry dicEntry in entries1) { Entry entry = (Entry)dicEntry.Value; if (!entry.IsDirectory) { if (LOGGER.IsDebugEnabled) { LOGGER.Debug("Found file=[" + entry.FullPath + "]"); } folder.Entries.Add (entry.FullPath, entry); } } folders.Add (folder); foreach (DictionaryEntry dicEntry in entries1) { Entry entry = (Entry)dicEntry.Value; if (entry.IsDirectory) { string childDir = Path.Combine(localDirectory, entry.Name); if (LOGGER.IsDebugEnabled) { LOGGER.Debug("Found directory=[" + childDir + "]"); } FetchFilesRecursive(folders, childDir); } } }
/// <summary> /// Add a new entry to the folders collection. /// </summary> /// <param name="folder"></param> /// <param name="entry"></param> public void AddEntry(string folder, Entry entry) { if (folders[folder] == null) { folders[folder] = new Folder(); } ((Folder)folders[folder]).Entries.Add(entry.FullPath, entry); }
/// <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; }