/// <summary> /// Creates a new instance of the command parser. /// </summary> /// <param name="command"></param> /// <param name="args"></param> /// <param name="cvsRoot"></param> /// <param name="workingDirectory"></param> public CommandParserFactory(string command, string[] args, CvsRoot cvsRoot, WorkingDirectory workingDirectory){ this.command = command; this.args = GetArgsAfterCommandName(args); this.cvsRoot = cvsRoot; this.workingDirectory = workingDirectory; }
/// <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); }
public void ValidRepositoryNames() { CvsRoot cvsRoot = new CvsRoot(":ext:[email protected]:/cvsroot/sharpcvslib-test"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharpcvslib-test", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":ext:[email protected]:/cvsroot/sharpcvslib.test"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharpcvslib.test", cvsRoot.CvsRepository); }
/// <summary> /// <code>true</code> if the two cvs roots are equal, otherwise <code>false</code>. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (null == obj) { return(false); } if (!obj.GetType().Equals(this.GetType())) { return(false); } CvsRoot root1 = (CvsRoot)obj; CvsRoot root2 = this; LOGGER.Debug(String.Format("root1: {0}; root2: {1}; are equal {2}", root1, root2, root1.ToString().Equals(root2.ToString()))); return(root1.ToString() == root2.ToString()); }
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> /// Parse the command line options. There are two (2) general sweeps /// at parsing the command line. The first sweep looks for command line /// help switches, denoted by -- parameters. /// </summary> /// <returns>A command object from the library which will be used to /// access the repsository.</returns> /// <exception cref="CommandLineParseException">If there is a problem /// parsing the command line arguments (i.e. if invalid arguments /// are entered.</exception> public ICommand Execute () { if (LOGGER.IsDebugEnabled) { StringBuilder msg = new StringBuilder (); msg.Append("\n Command line arguments:"); foreach (String argument in this.arguments) { msg.Append("\n\t argument=[").Append(argument).Append("]"); } LOGGER.Debug(msg); } bool isHelp = this.ParseHelp (this.arguments); if (isHelp) { return null; } int startIndex = 0; // TODO: Remove = null when all other code paths return a value, // this was just put in so it would compile. ICommand command = null; if (arguments.Length < 1) { System.Console.WriteLine (Usage.General); } if (arguments.Length > 0 && (arguments[0] == "-d")) { this.cvsRoot = new CvsRoot(this.arguments[1]); startIndex = 2; } else if (arguments.Length > 0 && (arguments[0].Length > 2) && arguments[0].Substring(0, 2) == "-d") { this.cvsRoot = new CvsRoot(this.arguments[0].Substring(2).Trim()); startIndex = 1; } for (int i = startIndex; i < arguments.Length; i++) { if (LOGGER.IsDebugEnabled) { StringBuilder msg = new StringBuilder (); msg.Append("arguments[").Append(i).Append("]=[").Append(arguments[i]).Append("]"); LOGGER.Debug(msg); } LOGGER.Debug("Before we grab the arguments."); string commandString = arguments[i].Trim(); CommandParserFactory factory; ICommandParser parser; switch (commandString) { case "add": case "ad": case "new": // no single options for the Add command this.commandTxt = arguments[i]; i++; // get rest of arguments which is options on the commit command. while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) { // Get options with second parameters? if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) { for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) { this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else { this.options = this.options + arguments[i++]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i) { // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.repository = arguments[i]; } else { this.repository = String.Empty; } AddCommandParser addCommand = new AddCommandParser(this.CvsRoot, repository, options); command = addCommand.CreateCommand (); this.currentWorkingDirectory = addCommand.CurrentWorkingDirectory; break; case "commit": case "ci": case "com": singleOptions = "DRcfln"; this.commandTxt = arguments[i]; i++; // get rest of arguments which is options on the commit command. while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) { LOGGER.Debug("Parsing arguments. Argument[" + i + "]=[" + arguments[i]); // Get options with second parameters? if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) { for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) { this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else { this.options = this.options + arguments[i++]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i) { // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.repository = arguments[i]; } else { this.repository = String.Empty; } CommitCommandParser commitCommand = new CommitCommandParser(this.CvsRoot, repository, options); command = commitCommand.CreateCommand (); this.currentWorkingDirectory = commitCommand.CurrentWorkingDirectory; break; case "checkout": case "co": case "get": singleOptions = "ANPRcflnps"; this.commandTxt = arguments[i]; i++; // get rest of arguments which is options on the checkout command. while (arguments.Length > i && arguments[i].Trim().IndexOf("-") == 0){ // Get options with second parameters? if (arguments[i].Trim().IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0){ for ( int cnt=1; cnt < arguments[i].Length; cnt++ ){ this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else{ this.options = this.options + arguments[i++]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i){ // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.repository = arguments[i]; } else { this.repository = String.Empty; } CheckoutCommandParser checkoutCommand = new CheckoutCommandParser(this.CvsRoot, this.Repository, options); command = checkoutCommand.CreateCommand (); this.currentWorkingDirectory = checkoutCommand.CurrentWorkingDirectory; break; case "import": case "imp": case "im": i++; string [] tempArgs = new string[arguments.Length - i]; Array.Copy(arguments, i, tempArgs, 0, arguments.Length - i); ImportCommandParser importCommand = new ImportCommandParser(this.CvsRoot, tempArgs); command = importCommand.CreateCommand(); this.currentWorkingDirectory = importCommand.CurrentWorkingDirectory; i = arguments.Length; break; case "init": this.commandTxt = arguments[i]; InitCommandParser initCommand = new InitCommandParser(this.CvsRoot); command = initCommand.CreateCommand (); this.currentWorkingDirectory = initCommand.CurrentWorkingDirectory; break; case "log": case "lo": this.commandTxt = arguments[i++]; string[] logArgs = new string[arguments.Length - i]; Array.Copy(arguments, i, logArgs, 0, arguments.Length - i); LogCommandParser logCommandParser = new LogCommandParser(this.CvsRoot, logArgs); command = logCommandParser.CreateCommand(); this.currentWorkingDirectory = logCommandParser.CurrentWorkingDirectory; i = arguments.Length; break; case "login": case "logon": case "lgn": // login to server this.commandTxt = arguments[i]; LoginCommand loginCommand = new LoginCommand(this.CvsRoot, this.currentWorkingDirectory); loginCommand.Args = arguments; this.currentWorkingDirectory = loginCommand.CurrentWorkingDirectory; command = loginCommand; break; case "dir": case "list": case "ls": factory = new CommandParserFactory("ls", arguments, this.cvsRoot, this.currentWorkingDirectory); parser = factory.GetCommandParser(); i = arguments.Length; command = parser.CreateCommand(); this.currentWorkingDirectory = parser.CurrentWorkingDirectory; break; case "passwd": case "password": case "setpass": this.commandTxt = arguments[i]; break; case "remove": case "delete": case "rm": singleOptions = "Rfl"; this.commandTxt = arguments[i]; i++; // get rest of arguments which is options on the update command. while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) { // Get options with second parameters? if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) { for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) { this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else { this.options = this.options + arguments[i]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i) { // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.files = arguments[i++]; } else { this.files = String.Empty; } RemoveCommandParser removeCommand = new RemoveCommandParser(this.CvsRoot, files, options); command = removeCommand.CreateCommand (); this.currentWorkingDirectory = removeCommand.CurrentWorkingDirectory; break; case "rt": case "rtag": case "rtfreeze": singleOptions = "abBdfFlMnR"; this.commandTxt = arguments[i++]; // get rest of arguments which is options on the rtag command. while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) { // Get options with second parameters? if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) { for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) { this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else { this.options = this.options + arguments[i]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i) { // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.repository = arguments[i++]; } else { this.repository = String.Empty; } RTagCommandParser rtagCommand = new RTagCommandParser(this.CvsRoot, repository, options); command = rtagCommand.CreateCommand (); this.currentWorkingDirectory = rtagCommand.CurrentWorkingDirectory; break; case "st": case "stat": case "status": string[] commandArgs = new string[arguments.Length - i]; Array.Copy(arguments, i, commandArgs, 0, arguments.Length - i); factory = new CommandParserFactory("status", commandArgs, this.cvsRoot, this.currentWorkingDirectory); parser = factory.GetCommandParser(); i = arguments.Length; command = parser.CreateCommand(); this.currentWorkingDirectory = parser.CurrentWorkingDirectory; break; case "up": case "upd": case "update": singleOptions = "ACPRbdfmp"; this.commandTxt = arguments[i++]; // get rest of arguments which is options on the update command. while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) { // Get options with second parameters? if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) { for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) { this.options = this.options + "-" + arguments[i][cnt] + " "; // No } } else { this.options = this.options + arguments[i]; // Yes this.options = this.options + arguments[i] + " "; } i++; } if (arguments.Length > i) { // Safely grab the module, if not specified then // pass null into the repository...the cvs command // line for cvsnt/ cvs seems to bomb out when // it sends to the server this.repository = arguments[i++]; } else { this.repository = String.Empty; } UpdateCommandParser updateCommand = new UpdateCommandParser(this.CvsRoot, repository, options); command = updateCommand.CreateCommand (); this.currentWorkingDirectory = updateCommand.CurrentWorkingDirectory; break; case "xml": factory = new CommandParserFactory("xml", arguments, this.cvsRoot, this.currentWorkingDirectory); // TODO: Move this outside of case statement when all commands use same pattern parser = factory.GetCommandParser(); i = arguments.Length; command = parser.CreateCommand(); this.currentWorkingDirectory = parser.CurrentWorkingDirectory; break; default: StringBuilder msg = new StringBuilder (); msg.Append("Unknown command entered. "); msg.Append("command=[").Append(arguments[i]).Append("]"); throw new CommandLineParseException(msg.ToString()); } } return command; }
public void MissingUserTest() { CvsRoot cvsRoot = new CvsRoot(":ext:@cvs.sourceforge.net:/cvsroot/sharpcvslib"); }
/// <summary> /// Commit changes in the cvs repository /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="fileNames">Files to remove</param> /// <param name="ciOptions">Options</param> public CommitCommandParser(CvsRoot cvsroot, string fileNames, string ciOptions) { this.cvsRoot = cvsroot; this.fileNames = fileNames; this.unparsedOptions = ciOptions; }
/// <summary> /// /// </summary> /// <param name="cvsRoot"></param> public LoginCommand (CvsRoot cvsRoot) { this.cvsRoot = cvsRoot; }
/// <summary> /// Update the given passfile with the root and password. If the /// .cvspass file does not exist it will be created. /// </summary> /// <param name="thePassword"></param> /// <param name="cvsRoot"></param> /// <param name="cvsPassFile"></param> public void UpdatePassFile (string thePassword, CvsRoot cvsRoot, FileInfo cvsPassFile) { if (!cvsPassFile.Exists) { this.Touch(cvsPassFile); } ArrayList passFileContents = this.ReadPassFile(cvsPassFile); ArrayList newPassFileContents = new ArrayList(); bool newRoot = true; foreach (string line in passFileContents) { string newLine = string.Empty; if (line.IndexOf(cvsRoot.ToString()) > -1) { newRoot = false; string[] passLineSplit = line.Split(' '); for (int i = 0; i < passLineSplit.Length; i++) { if (passLineSplit[i] == passLineSplit[passLineSplit.Length - 1]) { newLine += string.Format(" {0}", PasswordScrambler.Scramble(thePassword)); } else { newLine += string.Format(" {0}", passLineSplit[i]); } } } else { newLine = line; } newLine = newLine.Trim(); newPassFileContents.Add(newLine); } if (newRoot) { newPassFileContents.Add(string.Format("{0} {1}", cvsRoot.ToString(), PasswordScrambler.Scramble(thePassword))); } this.WritePassFile(cvsPassFile, newPassFileContents); }
/// <summary> /// Retrieve the cvs revision history for a file or group of files. /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="args">Commandline arguments.</param> public LogCommandParser(CvsRoot cvsroot, string[] args) { this.cvsRoot = cvsroot; this.unparsedOptions = args; }
/// <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> /// Default constructor - initializes all fields to default values /// </summary> public LogFile(CvsRoot cvsRoot) { this.repositoryFnm = ""; this.workingFnm = ""; this.description = ""; this.cvsRoot = cvsRoot; }
/// <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 a new instance of the log report command. /// </summary> /// <param name="workingDirectory"></param> /// <param name="module"></param> public LogReportCommand(WorkingDirectory workingDirectory, string module) { this.workingDirectory = workingDirectory; this.module = module; this.localDirectory = workingDirectory.LocalDirectory; this.cvsRoot = workingDirectory.CvsRoot; }
/// <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; }
public void MultiDotsTest() { CvsRoot cvsRoot = new CvsRoot(":ext:gne@.....:/cvsroot/sharpcvslib"); }
/// <summary> /// Produce an xml log report. /// </summary> public XmlLogCommandParser(CvsRoot cvsroot, string[] args) { // System.Console.WriteLine(String.Format("Number of arguments: {0}.", args.Length)); this.CvsRoot = cvsroot; this.ParseOptions(); }
public void MultiAtsTest() { CvsRoot cvsRoot = new CvsRoot(":ext:gne@@@@@@cvs.sourceforge.net:/cvsroot/sharpcvslib"); }
/// <summary> /// Remove file(s) in the cvs repository /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="fileNames">Files to remove</param> /// <param name="rmOptions">Options</param> public RemoveCommandParser(CvsRoot cvsroot, string fileNames, string rmOptions) { this.cvsRoot = cvsroot; this.fileNames = fileNames; this.unparsedOptions = rmOptions; }
/// <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; }
/// <summary> /// Constructor /// </summary> /// <param name="cvsroot"></param> public InitCommand(CvsRoot cvsroot) { this.cvsroot = cvsroot; }
/// <summary> /// Read the password string from the given .cvspass file. /// </summary> /// <param name="cvsRoot"></param> /// <returns></returns> public string ReadPassword (CvsRoot cvsRoot) { string pwd = String.Empty; ArrayList passFileContents = this.ReadPassFile(this.CvsPassFile); foreach (string line in passFileContents) { string[] passLineSplit = line.Split(' '); for (int i = 0; i < passLineSplit.Length; i++) { try { CvsRoot cvsRootTemp = new CvsRoot(passLineSplit[i]); if (cvsRootTemp.Equals(cvsRoot)) { return passLineSplit[i + 1]; } } catch (ICSharpCode.SharpCvsLib.Exceptions.CvsRootParseException) { // ignore, no match } } } return pwd; }
/// <summary> /// Add file(s) in the cvs repository /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="fileNames">Files to remove</param> /// <param name="adOptions">Options</param> public AddCommandParser(CvsRoot cvsroot, string fileNames, string adOptions) { this.cvsRoot = cvsroot; this.fileNames = fileNames; this.unparsedOptions = adOptions; }
public void UpdatePassFile (string thePassword, CvsRoot cvsRoot) { FileInfo passwordFile = this.CvsPassFile; this.UpdatePassFile(thePassword, cvsRoot, passwordFile); }
public void MissingRepositoryTest() { CvsRoot cvsRoot = new CvsRoot(":ext:[email protected]:"); }
/// <summary> /// Login to a cvs repository with workDirectory object /// </summary> /// <param name="cvsRoot">The repository root.</param> /// <param name="workingDirectory">User information</param> public LoginCommand(CvsRoot cvsRoot, WorkingDirectory workingDirectory){ this.cvsRoot = cvsRoot; this.workingDirectory = workingDirectory; // Is there a password file? // yes, get password for this username // no, prompt user for password to use }
public void MissingAmpersandTest() { CvsRoot cvsRoot = new CvsRoot(":ext:gne-cvs.sourceforge.net:/cvsroot/sharpcvslib"); }
public void MissingProtocolTest() { CvsRoot cvsRoot = new CvsRoot("::[email protected]:/cvsroot/sharpcvslib"); }
public void NoColonTest() { CvsRoot cvsRoot = new CvsRoot("[email protected]/cvsroot/sharpcvslib"); }
public void MissingHostTest() { CvsRoot cvsRoot = new CvsRoot(":ext:gne@:/cvsroot/sharpcvslib"); }
/// <summary> /// Constructor, parses out the orgainizational path response from /// the cvs server. /// </summary> /// <param name="workingDirectory">Contains information about the working /// repository.</param> /// <param name="repositoryPath">The relative path to the file served /// down from the cvs server.</param> public PathTranslator (WorkingDirectory workingDirectory, String repositoryPath) { this.baseDir = new DirectoryInfo(workingDirectory.LocalDirectory); this.moduleFacade = workingDirectory.WorkingDirectoryName; this.repositoryPath = repositoryPath; this.workingDirectory = workingDirectory; this.cvsRoot = workingDirectory.CvsRoot; this.relativePath = this.GetRelativePath (repositoryPath); this._currentDir = new DirectoryInfo(Path.Combine(Path.Combine(baseDir.FullName, this.workingDirectory.WorkingDirectoryName), this.relativePath)); }
public void MissingFirstColonTest() { CvsRoot cvsRoot = new CvsRoot("ext:[email protected]:/cvsroot/sharpcvslib"); System.Console.WriteLine(cvsRoot); }
/// <summary> /// Update modules or files in the cvs repository /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="fileNames">Files</param> /// <param name="upOptions">Options</param> public StatusCommandParser(CvsRoot cvsroot, string fileNames, string upOptions) { this.cvsRootVar = cvsroot; this.fileNames = fileNames; this.unparsedOptions = upOptions; }
public void MissingThirdColonTest() { CvsRoot cvsRoot = new CvsRoot(":ext:[email protected]/cvsroot/sharpcvslib"); }
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); }
public void NoUserTestNoException() { CvsRoot localProtocol = new CvsRoot(":local:cvs.sourceforge.net:/cvsroot/sharpcvslib"); CvsRoot sspiProtocol = new CvsRoot(":sspi:cvs.sourceforge.net:/cvsroot/sharpcvslib"); }
/// <summary> /// Create a new <see cref="ListCommand"/>, initialize the variables that are used /// in a checkout. /// </summary> /// <param name="cvsRoot">The cvs root to use for this checkout.</param> /// <param name="args">Commandline arguments to be parsed out and used for the command.</param> public ListCommandParser (CvsRoot cvsRoot, string[] args) { this.CvsRoot = cvsRoot; StringBuilder coOptions = new StringBuilder (); foreach (string arg in args) { coOptions.Append(arg); } this.unparsedOptions = coOptions.ToString(); }
public void InvalidAddressTest() { CvsRoot cvsRoot = new CvsRoot(":ext:gne[cvs.sourceforge.net:/cvsroot/sharpcvslib"); }
public ListCommandParser (CvsRoot cvsRoot, string repositoryName, string coOptions) { this.CvsRoot = cvsRoot; repository = repositoryName; this.unparsedOptions = coOptions; }
public void ValidCvsRootTest() { CvsRoot cvsRoot = new CvsRoot(":ext:[email protected]:/cvsroot/sharpcvslib"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharpcvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":ext:[email protected]:2401:/cvsroot/sharpcvslib"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharpcvslib", cvsRoot.CvsRepository); Assert.AreEqual(2401, cvsRoot.Port); cvsRoot = new CvsRoot(":ext:[email protected]:d:/cvsroot/sharpcvslib"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("d:/cvsroot/sharpcvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":ext:[email protected]:2401:d:/cvsroot/sharpcvslib"); Assert.AreEqual("ext", cvsRoot.Protocol); Assert.AreEqual("gne", cvsRoot.User); Assert.AreEqual(2401, cvsRoot.Port); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("d:/cvsroot/sharpcvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":sspi:cvs.sourceforge.net:d:/cvsroot/sharpcvslib"); Assert.AreEqual("sspi", cvsRoot.Protocol); Assert.AreEqual("cvs.sourceforge.net", cvsRoot.Host); Assert.AreEqual("d:/cvsroot/sharpcvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharpcvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("anonymous", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharpcvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp-cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp-cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp$cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp$cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp%cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp%cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp'cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp'cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp`cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp`cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp@cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp@cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp(cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp(cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp)cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp)cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp~cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp~cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp!cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp!cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp#cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp#cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp{cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp{cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp}cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp}cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp&cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp&cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp_cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp_cvslib", cvsRoot.CvsRepository); cvsRoot = new CvsRoot(":pserver:[email protected]:/cvsroot/sharp^cvslib"); Assert.AreEqual("pserver", cvsRoot.Protocol); Assert.AreEqual("drakmar", cvsRoot.User); Assert.AreEqual("cvs.source-forge.net", cvsRoot.Host); Assert.AreEqual("/cvsroot/sharp^cvslib", cvsRoot.CvsRepository); }
/// <summary> /// RTags in the cvs repository /// </summary> /// <param name="cvsroot">User Information</param> /// <param name="repository">Repository that contains the files to be tagged</param> /// <param name="rtOptions">Options</param> public RTagCommandParser(CvsRoot cvsroot, string repository, string rtOptions) { this.cvsRoot = cvsroot; this.repository = repository; this.unparsedOptions = rtOptions; }