private void Checkout() { CvsRoot cvsRoot; try { cvsRoot = this.GetCvsRoot(this.CvsRoot.Text); } catch (CvsRootParseException ex) { this.ErrorLabel.Text = ex.Message; // can't do anything without a root. return; } WorkingDirectory CurrentWorkingDirectory = new WorkingDirectory(cvsRoot, this.LocalDirectory.Text, Module.Text); // Create new CheckoutModuleCommand object ICommand checkoutCommand = new CheckoutModuleCommand(CurrentWorkingDirectory); CVSServerConnection serverConn = new CVSServerConnection(CurrentWorkingDirectory); this.RegisterListenEvents(serverConn); serverConn.Connect(CurrentWorkingDirectory, this.Password.Text); checkoutCommand.Execute(serverConn); serverConn.Close(); }
/// <summary> /// Checkout the test repository. This repository is configured in the /// ICSharpConfig.SharpCvsLib.Tests.dll.config file, or if this file /// cannot be found or loaded then the settings are loaded from /// TestConstants class. /// </summary> public void CheckoutTestModule() { 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); 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(); }
/// <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); }
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))); }
private void Checkout() { CvsRoot root = new CvsRoot(this.settings.Config.Cvsroot); WorkingDirectory working = new WorkingDirectory(root, this.settings.Config.LocalPath, this.settings.Config.Module); 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."); connection.Connect(working, this.settings.Config.ValidPassword); command.Execute(connection); connection.Close(); }
public void ParseOptions() { String commandLine = "-d:pserver:[email protected]:/cvsroot/sharpcvslib co -r v0_3_1 -d newLocation sharpcvslib"; String[] args = commandLine.Split(' '); CommandLineParser parser = new CommandLineParser(args); try { LOGGER.Debug("Before execute ParseOptions."); ICommand command = parser.Execute(); Assert.IsTrue(command.GetType() == typeof(CheckoutModuleCommand)); CheckoutModuleCommand co = (CheckoutModuleCommand)command; Assert.AreEqual("v0_3_1", co.Revision); Assert.AreEqual("newlocation", co.OverrideDirectory); } catch (Exception e) { LOGGER.Error(e); throw e; } }