Example #1
0
        /// <summary>
        ///     Perform a checkout command using the values in the
        ///         The revision tag
        ///         (if specified) is also used to select the code
        ///         to checkout.
        /// </summary>
        /// <param name="revision">The specific revision of the module
        ///     to checkout from the repository.  If <code>null</code>
        ///     is specified then the default revision, usually the
        ///     <code>HEAD</code> is checked out.</param>
        /// <param name="overrideDirectory">The override directory to
        ///     checkout the repository to.  If <code>null</code>
        ///     is specified then the directory is not overridden
        ///     and the module name is used.</param>
        public void Checkout(String revision, String overrideDirectory)
        {
            CvsRoot          root    = new CvsRoot(this.settings.Config.Cvsroot);
            WorkingDirectory working =
                new WorkingDirectory(root,
                                     this.settings.Config.LocalPath,
                                     this.settings.Config.Module);

            System.Console.WriteLine(this.settings.Config.LocalPath);

            working.Revision          = revision;
            working.OverrideDirectory = overrideDirectory;

            CVSServerConnection connection = new CVSServerConnection();

            Assert.IsNotNull(connection, "Should have a connection object.");

            ICommand command = new CheckoutModuleCommand(working);

            Assert.IsNotNull(command, "Should have a command object.");

            try {
                connection.Connect(working, this.settings.Config.ValidPassword);
            } catch (AuthenticationException) {
                Assert.IsTrue(true, "Failed to authenticate with server.");
            }

            command.Execute(connection);
            connection.Close();
        }
        public void UpdateFromCvsntTest_Checkout()
        {
            string cvsPath =
                Path.Combine(this.settings.Config.LocalPath, CVSNT_MODULE);
            Manager manager = new Manager(cvsPath);

            CvsRoot          root    = new CvsRoot(CVSNT_CVSROOT);
            WorkingDirectory working =
                new WorkingDirectory(root,
                                     this.settings.Config.LocalPath,
                                     CVSNT_MODULE);

            CVSServerConnection connection = new CVSServerConnection();

            Assert.IsNotNull(connection);

            ICommand command = new CheckoutModuleCommand(working);

            Assert.IsNotNull(command);

            try {
                connection.Connect(working, this.settings.Config.ValidPassword);
            } catch (AuthenticationException) {
                Assert.IsTrue(true);
            }

            command.Execute(connection);
            connection.Close();

            this.PerformUpdate();
        }
        private void Checkout(WorkingDirectory workingDirectory, CVSServerConnection connection)
        {
            Assert.IsNotNull(connection);

            ICommand command = new CheckoutModuleCommand(workingDirectory);

            Assert.IsNotNull(command);

            try {
                connection.Connect(workingDirectory, this.settings.Config.ValidPassword);
            } catch (AuthenticationException) {
                Assert.IsTrue(true);
            }

            command.Execute(connection);
            connection.Close();
        }
Example #4
0
        public IExternalSource Checkout(string cvsroot, string module, string password, 
            out string target)
        {
            //Set temp checkout dir
            target = System.IO.Path.Combine(Globals.TempDirectory, Guid.NewGuid().ToString());
            Directory.CreateDirectory(target);

            //Setup CVS vars
            CvsRoot root = new CvsRoot(cvsroot);
            WorkingDirectory working = new WorkingDirectory(root, target, module);

            CVSServerConnection connection = new CVSServerConnection();
            if (connection == null)
                throw new ToolExecutionException("Unable to connect to the CVS server");

            //Connect to CVS
            ICSharpCode.SharpCvsLib.Commands.ICommand command =
                new CheckoutModuleCommand(working);
            if (command == null)
                throw new ToolExecutionException("Failure to create a checkout command object");
            try {
                connection.Connect(working, password);
            } catch (AuthenticationException) {
                throw new ToolExecutionException("CVS rejected access (doublecheck all fields): Authentication failure");
            } catch (Exception er) {
                throw new ToolExecutionException("CVS rejected access (doublecheck all fields): " + er.Message);
            }

            //Execute checkout command
            try {
                command.Execute(connection);
                connection.Close();
            } catch (Exception er) {
                throw new ToolExecutionException("CVS error: " + er.Message);
            }

            //Create source from module root
            return CreateSource(Path.Combine(target, module));
        }
 /// <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 () {
     CheckoutModuleCommand checkoutCommand;
     try {
         this.ParseOptions(this.unparsedOptions);
         // create CvsRoot object parameter
         if (localDirectory == null) {
             localDirectory = Environment.CurrentDirectory;
         }
         this.CurrentWorkingDirectory = new WorkingDirectory(this.cvsRoot,
             localDirectory, repository);
         if (revision != null) {
             this.CurrentWorkingDirectory.Revision = revision;
         }
         if (!date.Equals(DateTime.MinValue)) {
             this.CurrentWorkingDirectory.Date = date;
         }
         // Create new CheckoutModuleCommand object
         checkoutCommand = new CheckoutModuleCommand(this.CurrentWorkingDirectory);
     }
     catch (Exception e) {
         LOGGER.Error (e);
         throw e;
     }
     return checkoutCommand;
 }