/// <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);
        }
示例#2
0
        /// <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);
                }
            }
        }
        /// <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.LogCommand logCommand;
            DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());

            this.ParseOptions(this.unparsedOptions);
            try {
                Repository repository = Repository.Load(dir);
                if (null == repository || null == repository.FileContents)
                {
                    throw new CvsFileNotFoundException(
                              string.Format("Valid CVS\\Repository file not found in {0}",
                                            dir));
                }
                this.repository = repository.FileContents;
                Root root = Root.Load(dir);
                if (null == root || null == root.FileContents)
                {
                    throw new CvsFileNotFoundException(
                              string.Format("Valid CVS\\Root file not found in {0}",
                                            dir));
                }
                this.cvsRoot = new CvsRoot(root.FileContents);
            } catch (CvsFileNotFoundException e) {
                LOGGER.Error(e);
                ConsoleMain.ExitProgram("Not a CVS repository.", e);
            }

            CurrentWorkingDirectory = new WorkingDirectory(this.cvsRoot,
                                                           dir.FullName, this.repository);


            logCommand =
                new ICSharpCode.SharpCvsLib.Commands.LogCommand(
                    CurrentWorkingDirectory, folders);

            return(logCommand);
        }
示例#4
0
        /// <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;
            }
        }