/// <summary>
        /// Process the response from the cvs server.
        /// </summary>
        public override void Process() {
            Manager manager = new Manager (Services.Repository.WorkingPath);
            string localPath = this.ReadLine();
            string reposPath = this.ReadLine();
            string entry     = this.ReadLine();
            string flags     = this.ReadLine();
            string sizeStr   = this.ReadLine();

            PathTranslator orgPath   =
                new PathTranslator (Services.Repository,
                                    reposPath);
            string localPathAndFilename = orgPath.LocalPathAndFilename;
            string directory = orgPath.LocalPath;

            bool compress = sizeStr[0] == 'z';

            if (compress) {
                sizeStr = sizeStr.Substring(1);
            }

            int size  = Int32.Parse(sizeStr);

            if (!Directory.Exists(orgPath.LocalPath)) {
                Directory.CreateDirectory(orgPath.LocalPath);

            }

            if (Services.NextFile != null && Services.NextFile.Length > 0) {
                localPathAndFilename = Services.NextFile;
                Services.NextFile = null;
            }

            Factory factory = new Factory();
            Entry e = (Entry)
                factory.CreateCvsObject(new DirectoryInfo(Path.GetDirectoryName(orgPath.CurrentDir.FullName)), 
                Entry.FILE_NAME, entry);

            if (e.IsBinaryFile) {
                Services.UncompressedFileHandler.ReceiveBinaryFile(Stream,
                        localPathAndFilename,
                        size);
            } else {
                Services.UncompressedFileHandler.ReceiveTextFile(Stream,
                        localPathAndFilename,
                        size);
            }

            e.Date = Services.NextFileDate;
            Services.NextFileDate = null;

            manager.AddEntry(e);
            manager.SetFileTimeStamp (e.FullPath, e.TimeStamp, e.IsUtcTimeStamp);

            UpdateMessage message = new UpdateMessage ();
            message.Module = Services.Repository.WorkingDirectoryName;
            message.Repository =  orgPath.RelativePath;
            message.Filename = e.Name;
            Services.SendMessage (message.Message);
            Services.ResponseMessageEvents.SendResponseMessage(message.Message, this.GetType());
        }
        /// <summary>
        /// Process the response stream.
        /// </summary>
        public override void Process() {
            string localPath      = this.ReadLine();
            string repositoryPath = this.ReadLine();
            string stickyTag      = this.ReadLine();

            PathTranslator orgPath   =
                new PathTranslator (Services.Repository, repositoryPath);

            string localPathAndFilename = orgPath.LocalPathAndFilename;
            string directory = orgPath.LocalPath;

            Manager manager = 
                new Manager (Services.Repository.WorkingPath);
            manager.AddTag (Services.Repository, localPath, repositoryPath, stickyTag);

        }
        /// <summary>
        /// Process a new entry response.
        /// 
        /// TODO: Copied implementation from CheckedInResponse, determine if this
        ///     is correct or not.
        /// </summary>
        public override void Process() {
            string localPath      = this.ReadLine();
            string repositoryPath = this.ReadLine();
            string entryLine      = this.ReadLine();

            PathTranslator orgPath   =
                new PathTranslator (Services.Repository,
                repositoryPath);

            string fileName = orgPath.LocalPathAndFilename;
            Factory factory = new Factory();
            Entry  entry = (Entry)
                factory.CreateCvsObject(orgPath.CurrentDir, Entry.FILE_NAME, entryLine);
            Manager manager = new Manager (Services.Repository.WorkingPath);
            manager.Add (entry);
        }
        /// <summary>
        /// Process a clear static directory response.
        /// </summary>
        public override void Process() {
            string localPath      = this.ReadLine();
            string reposPath      = this.ReadLine();

            Manager manager = new Manager (Services.Repository.WorkingPath);
            manager.AddRepository (Services.Repository, localPath, reposPath);
            manager.AddRoot (Services.Repository, localPath, reposPath);
            PathTranslator pathTranslator = new PathTranslator (Services.Repository, reposPath);

            Factory factory = new Factory();
            Entry entry = 
                (Entry)factory.CreateCvsObject(pathTranslator.CurrentDir, Entry.FILE_NAME, 
                Entry.CreateEntry(pathTranslator.CurrentDir).FileContents);
            // the root module directory does not get a cvs Entries line.
            // TODO: There has to be a cleaner way to do this...
            if (Services.Repository.WorkingPath.Length <= entry.Path.Length) {
                manager.AddEntry(entry);
            }

            Services.ResponseMessageEvents.SendResponseMessage(
                String.Format("Updating {0}", RemoveTrailingSlash(localPath)), this.GetType());
        }
 /// <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.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.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>
 /// Lookup the password for the given file
 /// </summary>
 /// <returns></returns>
 private string GetPassword () {
     Manager manager = new Manager(this.Repository.LocalDirectory);
     return PasswordScrambler.Descramble(manager.ReadPassword(this.CvsRoot));
 }
Beispiel #9
0
 /// <summary>
 /// Load the root file.
 /// </summary>
 /// <param name="tagFile"></param>
 /// <returns></returns>
 public static Tag Load (FileInfo tagFile) {
     if (tagFile.Name != Tag.FILE_NAME) {
         throw new ArgumentException(string.Format("Not a valid Tag file, {0}",
             tagFile.FullName));
     }
     Manager manager = new Manager(tagFile.DirectoryName);
     return manager.FetchTag(tagFile.DirectoryName);
 }
        /// <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;
            }
        }
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="cvsroot">The cvs root string, contains information
 ///     about the connection and path on the cvs server.</param>
 /// <param name="localdirectory">The local base directory to check the
 ///     module out in.</param>
 /// <param name="moduleName">The name of the module.  This is
 ///     appended to the base localdirectory to check the sources out into.</param>
 public WorkingDirectory(    CvsRoot cvsroot,
                             string localdirectory,
                             string moduleName) {
     this.repositoryname = moduleName;
     this.cvsroot        = cvsroot;
     this.localDir = new DirectoryInfo(localdirectory);
     this.manager = new Manager(this.WorkingPath);
 }
        /// <summary>
        /// Produce the report
        /// Alternate interface for when we are given a server cooection
        /// This is needed for the SharpCvsLib command line client
        /// </summary>
        public LogReport Run(ICommandConnection connection)
        {
           // read Root and Repository from local directory
            if (null == this.cvsRoot) {
                Manager manager = new Manager(localDirectory);
                Root root = (Root)manager.FetchSingle (localDirectory,
                    Factory.FileType.Root);
        
                this.cvsRoot = new CvsRoot(root.FileContents);
            }

            if (null == workingDirectory) {
                Manager manager = new Manager(localDirectory);
                Repository repository = (Repository)manager.FetchSingle (localDirectory,
                    Factory.FileType.Repository);

                this.workingDirectory = new WorkingDirectory(cvsRoot,
                    localDirectory,
                    repository.FileContents);
            }
        
            ILogCommand command;
            // Recursively add all cvs folders/files under the localDirectory
System.Console.WriteLine("GNE workingDirectory.WorkingPath = {0}", workingDirectory.WorkingPath);
System.Console.WriteLine("GNE localDirectory: {0}", localDirectory);
 //           if (Directory.Exists(workingDirectory.WorkingPath)) {
            if (Directory.Exists(localDirectory) && File.Exists(Path.Combine(localDirectory, "Repository"))) {
                workingDirectory.FoldersToUpdate = FetchFiles(localDirectory);
                command = 
                    new LogCommand(workingDirectory, this.workingDirectory.ModuleName, null);
            } else {
                command = 
// GNE - this wont compile                   new LogCommand(workingDirectory, this.workingDirectory.ModuleName);
                    new RLogCommand(workingDirectory, this.workingDirectory.ModuleName);
            }
    
            // add any date restrictions        
            if (hasStartDate && hasEndDate) {
            	command.AddInclusiveDateRange(startDate, endDate);
            } else if (hasStartDate) {
            	command.AddInclusiveDateStart(startDate);
            } else if (hasEndDate) {
            	command.AddInclusiveDateEnd(endDate);
            }
     
            // Initialse state machine
            curLogReport = new LogReport(); // this is what we are going to return to the caller
            curLogFile = new LogFile(this.cvsRoot);
            curLogRevision = new LogRevision();
            logState = LogState.WANT_FILE_HEADER_START;
             
            if (connection.GetType() == typeof(CVSServerConnection)) {
                CVSServerConnection cvsServerConnection = (CVSServerConnection)connection;
                cvsServerConnection.MessageEvent.MessageEvent += new EncodedMessage.MessageHandler(OnMessage);
            }
            command.Execute(connection);

            // return curLogReport but clear our reference to it
            LogReport report = curLogReport;
            curLogReport = null;
            return report;
        }
        /// <summary>
        /// Produce the report
        /// </summary>
        public LogReport Run(string password)
        {
          // read Root and Repository from local directory
            if (null == this.cvsRoot) {
                Manager manager = new Manager(localDirectory);
                Root root = (Root)manager.FetchSingle (localDirectory,
                    Factory.FileType.Root);
                cvsRoot = new CvsRoot(root.FileContents);
            }
           
            if (null == this.workingDirectory) {
                workingDirectory = new WorkingDirectory(cvsRoot,
                    localDirectory,
                    module);
            }
            
            // Get a connection
            CVSServerConnection connection = new CVSServerConnection();

        	connection.Connect(workingDirectory, password);
        	
        	return Run(connection);
        }
        /// <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.ImportModuleCommand importCommand;
            try {
                this.ParseOptions(this.unparsedOptions);
                CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot,
                    Environment.CurrentDirectory, this.repository);
                Manager manager = new Manager(Environment.CurrentDirectory);

                DirectoryInfo importDir = new DirectoryInfo(Environment.CurrentDirectory);

                if (!importDir.Exists) {
                    ConsoleMain.ExitProgram("Import directory does not exist.");
                }

                CurrentWorkingDirectory.Folders = 
                    manager.FetchFilesToAdd(importDir.FullName);
                importCommand = 
                    new ICSharpCode.SharpCvsLib.Commands.ImportModuleCommand(
                    CurrentWorkingDirectory, this.message);

                importCommand.VendorString = this.vendor;
                importCommand.ReleaseString = this.release;
                importCommand.LogMessage = this.message;
//                importCommand.Repository = this.repository;
            }
            catch (Exception e) {
                LOGGER.Error (e);
                throw e;
            }
            return importCommand;
        }
        /// <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 () {
            DirectoryInfo dir = 
                new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "CVS"));

            UpdateCommand2 updateCommand;

            this.ParseOptions(this.unparsedOptions);
            // note the sandbox is actually above the CVS directory
            Manager manager = new Manager(dir.Parent);

            Repository repository = null;
            Root root = null;

            try {
                repository = Repository.Load(dir); 
                root = Root.Load(dir);
            } catch (NullReferenceException) {
                this.InvalidRepository();
            } catch (CvsFileNotFoundException) {
                this.InvalidRepository();
            }

            if (null == repository) {
                this.InvalidRepository();
            }

            try {
                this.cvsRootVar = new CvsRoot(root.FileContents);
            } catch (ICSharpCode.SharpCvsLib.Exceptions.CvsRootParseException) {
                this.InvalidRepository();
            }

            // If this fails error out and state the user
            //    is not in a CVS repository directory tree.
            if (localDirectory == null) {
                localDirectory = dir.Parent.FullName;
            }
            CurrentWorkingDirectory = new WorkingDirectory( this.CvsRootVar,
                localDirectory, repository.FileContents);
            if (revision != null) {
                CurrentWorkingDirectory.Revision = revision;
            }
            if (!date.Equals(DateTime.MinValue)) {
                CurrentWorkingDirectory.Date = date;
            }
            CurrentWorkingDirectory.FoldersToUpdate =
                manager.FetchFilesToUpdate (dir.FullName);
            // Create new UpdateCommand2 object
            updateCommand = new UpdateCommand2(CurrentWorkingDirectory);

            return updateCommand;
        }
 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);
 }
Beispiel #17
0
        /// <summary>
        /// Execute checkout module command.
        /// 
        /// taken from: http://www.elegosoft.com/cvs/cvsclient.html
        /// add \n
        ///     Response expected: yes. Add a file or directory. This uses any 
        ///     previous Argument, Directory, Entry, or Modified requests, if they 
        ///     have been sent. The last Directory sent specifies the working 
        ///     directory at the time of the operation. To add a directory, send the 
        ///     directory to be added using Directory and Argument requests.
        ///
        /// </summary>
        /// <example>
        /// 
        /// C: Root /u/cvsroot
        /// . . .
        /// C: Argument nsdir
        /// C: Directory nsdir
        /// C: /u/cvsroot/1dir/nsdir
        /// C: Directory .
        /// C: /u/cvsroot/1dir
        /// C: add
        /// S: M Directory /u/cvsroot/1dir/nsdir added to the repository
        /// S: ok
        ///
        /// You will notice that the server does not signal to the client in any 
        /// particular way that the directory has been successfully added. The client 
        /// is supposed to just assume that the directory has been added and update 
        /// its records accordingly. Note also that adding a directory is immediate; 
        /// it does not wait until a ci request as files do. To add a file, send the 
        /// file to be added using a Modified request. For example:
        ///
        /// C: Argument nfile
        /// C: Directory .
        /// C: /u/cvsroot/1dir
        /// C: Modified nfile
        /// C: u=rw,g=r,o=r
        /// C: 6
        /// C: hello
        /// C: add
        /// S: E cvs server: scheduling file `nfile' for addition
        /// S: Mode u=rw,g=r,o=r
        /// S: Checked-in ./
        /// S: /u/cvsroot/1dir/nfile
        /// S: /nfile/0///
        /// S: E cvs server: use 'cvs commit' to add this file permanently
        /// S: ok
        ///
        /// Note that the file has not been added to the repository; the only effect 
        /// of a successful add request, for a file, is to supply the client with a 
        /// new entries line containing `0' to indicate an added file. In fact, the 
        /// client probably could perform this operation without contacting the 
        /// server, although using add does cause the server to perform a few more 
        /// checks. The client sends a subsequent ci to actually add the file to the 
        /// repository. Another quirk of the add request is that with CVS 1.9 and 
        /// older, a pathname specified in an Argument request cannot contain `/'. 
        /// There is no good reason for this restriction, and in fact more recent 
        /// CVS servers don't have it. But the way to interoperate with the older 
        /// servers is to ensure that all Directory requests for add (except those 
        /// used to add directories, as described above), use `.' for local-directory. 
        /// Specifying another string for local-directory may not get an error, but 
        /// it will get you strange Checked-in responses from the buggy servers.
        /// </example>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection) {
            connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH));
            int loops = 0;
            foreach (DictionaryEntry folderEntry in this.Folders) {
                LOGGER.Debug("loops=[" + loops++ + "]");
                Folder folder = (Folder)folderEntry.Value;
                this.SetDirectory (connection, folder);

                // send each is-modified request
                foreach (DictionaryEntry entryEntry in folder.Entries) {
                    Entry entry = (Entry)entryEntry.Value;
                    //connection.SubmitRequest(new IsModifiedRequest(entry.Name));

                    //String fileName = Path.Combine(entry.Path, entry.Name);
                    this.SendFileRequest (connection, entry);

                    // Add the file to the cvs entries file
                    Manager manager = new Manager(connection.Repository.WorkingPath);
                    manager.Add(entry);
                    if (LOGGER.IsDebugEnabled) {
                        LOGGER.Debug("AddCommand.  Entry=[" + entry + "]");
                    }
                }

                // send each argument request
                foreach (DictionaryEntry entryEntry in folder.Entries) {
                    Entry entry = (Entry)entryEntry.Value;
                    connection.SubmitRequest(new ArgumentRequest(entry.Name));

                    //String fileName = Path.Combine(entry.Path, entry.Name);
                    //this.SendFileRequest (connection, entry);

                    // Add the file to the cvs entries file
                    Manager manager = new Manager(connection.Repository.WorkingPath);
                    manager.Add(entry);
                    if (LOGGER.IsDebugEnabled) {
                        LOGGER.Debug("AddCommand.  Entry=[" + entry + "]");
                        Entries entries = manager.FetchEntries(entry.FullPath);
                        foreach (DictionaryEntry dicEntry in entries) {
                            LOGGER.Debug("entry=[" + dicEntry.Value + "]");
                        }
                    }
                }
            }

            connection.SubmitRequest(new AddRequest());
        }
        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>
 /// 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;
 }
        /// <summary>
        /// Process the login command with cvs library API calls.
        /// </summary>
        public void Execute () {
            if (null != this.CvsRoot && this.CvsRoot.TransportProtocol != 
                ICSharpCode.SharpCvsLib.Misc.CvsRoot.ProtocolType.pserver) {
                LOGGER.Debug(string.Format("cvs [login aborted]: The :{0}: protocol does not support the login command",
                    this.CvsRoot.Protocol));
                return;
            }

            CVSServerConnection serverConn = 
                new CVSServerConnection(CurrentWorkingDirectory);
            try {
                serverConn.Connect(CurrentWorkingDirectory, password);
            } catch (ICSharpCode.SharpCvsLib.Exceptions.AuthenticationException) {
                try {
                    this.password = 
                        PServerProtocol.PromptForPassword(this.CvsRoot.ToString());
                    if (this.password == null) {
                        this.password = string.Empty;
                    }
                    Manager manager = new Manager(this.workingDirectory.LocalDirectory);
                    manager.UpdatePassFile(this.password, this.CvsRoot);

                    serverConn.Connect(CurrentWorkingDirectory, password);
                } catch (ICSharpCode.SharpCvsLib.Exceptions.AuthenticationException e) {
                    ConsoleMain.ExitProgram(e.Message);
                }
            }
        }
Beispiel #21
0
 private static Entries LoadImpl (FileInfo cvsFile) {
     Manager manager = new Manager(cvsFile.DirectoryName);
     return manager.FetchEntries(cvsFile.FullName);
 }
Beispiel #22
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);
 }
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection) {
            workingDirectory.Clear();

            //connection.SubmitRequest(new CaseRequest());
            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                    workingDirectory.CvsRoot.CvsRepository +
                                    "/" + workingDirectory.ModuleName));

            connection.SubmitRequest(new ExpandModulesRequest());

            connection.SubmitRequest(
                new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME));

            if (null != this.Revision) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION));
                connection.SubmitRequest(new ArgumentRequest(this.Revision));
            }
            if (this._hasDate) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE));
                connection.SubmitRequest(new ArgumentRequest(this.DateAsString));
            }
            if (null != this.OverrideDirectory) {
                connection.SubmitRequest (
                    new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                connection.SubmitRequest (
                    new ArgumentRequest (this.OverrideDirectory));
            }

            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                    workingDirectory.CvsRoot.CvsRepository +
                                    "/" + this.Module));

            connection.SubmitRequest(new CheckoutRequest());
            Manager manager = new Manager (connection.Repository.WorkingPath);
        }