From: <sk...@us...> - 2003-11-14 22:28:24
|
Update of /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Console/SharpCvsLib/Console/Commands In directory sc8-pr-cvs1:/tmp/cvs-serv31768/src/ICSharpCode.Console/SharpCvsLib/Console/Commands Modified Files: CheckoutCommand.cs Log Message: Added Options parameter to Checkout command. Index: CheckoutCommand.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Console/SharpCvsLib/Console/Commands/CheckoutCommand.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CheckoutCommand.cs 5 Nov 2003 08:07:28 -0000 1.3 --- CheckoutCommand.cs 14 Nov 2003 22:28:18 -0000 1.4 *************** *** 33,37 **** --- 33,39 ---- using System; + using System.Globalization; using System.IO; + using System.Text; using ICSharpCode.SharpCvsLib.Misc; using ICSharpCode.SharpCvsLib.Commands; *************** *** 48,51 **** --- 50,56 ---- private string cocvsroot; private string repository; + private string revision; + private string localDirectory; + private DateTime date; /// <summary> *************** *** 54,60 **** /// <param name="cvsroot">User information</param> /// <param name="repositoryName">Repository</param> ! public CheckoutCommand(string cvsroot, string repositoryName){ cocvsroot = cvsroot; repository = repositoryName; } /// <summary> --- 59,169 ---- /// <param name="cvsroot">User information</param> /// <param name="repositoryName">Repository</param> ! /// <param name="coOptions">Options</param> ! public CheckoutCommand(string cvsroot, string repositoryName, string coOptions){ ! int endofOptions = 0; cocvsroot = cvsroot; repository = repositoryName; + // get Checkout Options and parameters + for (int i = 0; i < coOptions.Length; i++){ + if (coOptions[i]== '-' && coOptions[i+1] == 'r'){ + i += 2; + // get revision of files to checkout + if (coOptions.IndexOf(" -", i, coOptions.Length - i) == -1){ + endofOptions = coOptions.Length - i - 1; + } + else{ + endofOptions = coOptions.IndexOf(" -", i, coOptions.Length - i) - 2; + } + revision = coOptions.Substring(i, endofOptions); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'd'){ + i += 2; + // get location to place files locally + if (coOptions.IndexOf(" -", i, coOptions.Length - i) == -1){ + endofOptions = coOptions.Length - i - 1; // minus one so not to + // include last space + } + else{ + endofOptions = coOptions.IndexOf(" -", i, coOptions.Length - i) - 2; + } + localDirectory = coOptions.Substring(i, endofOptions); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'D'){ + i += 2; + // get date of files to checkout + // Date format needs to be the short date pattern as stated in the + // Control Panel -> Regional Options -> see Date tab + if (coOptions.IndexOf(" -", i, coOptions.Length - i) == -1){ + endofOptions = coOptions.Length - i - 1; // minus one so not to + // include last space + } + else{ + endofOptions = coOptions.IndexOf(" -", i, coOptions.Length - i) - 2; + } + try{ + // Parse string to DateTime format + string datepar = coOptions.Substring(i, endofOptions); + date = System.Convert.ToDateTime(datepar, DateTimeFormatInfo.CurrentInfo); + } + catch{ + StringBuilder msg = new StringBuilder (); + msg.Append("The -D checkout option parameter is not "); + msg.Append("in correct format of "); + msg.Append(DateTimeFormatInfo.CurrentInfo.ShortDatePattern); + msg.Append("."); + throw new ApplicationException (msg.ToString()); + } + } + if (coOptions[i]== '-' && coOptions[i+1] == 'A'){ + String msg = "The -A checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'N'){ + String msg = "The -N checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'P'){ + String msg = "The -P checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'R'){ + String msg = "The -R checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'c'){ + String msg = "The -c checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'f'){ + String msg = "The -f checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'l'){ + String msg = "The -l checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'n'){ + String msg = "The -n checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 'p'){ + String msg = "The -p checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + if (coOptions[i]== '-' && coOptions[i+1] == 's'){ + String msg = "The -s checkout option is not " + + "implemented."; + throw new ApplicationException (msg); + } + } } /// <summary> *************** *** 66,78 **** // create CvsRoot object parameter CvsRoot root = new CvsRoot(cocvsroot); ! // need CvsRoot object and two strings to ! //create new WorkingDirectory object parameter ! // CvsRoot cvsroot, ! // string localdirectory, < use current directory > ! //string repositoryname) < name of the module> example is sharpcvslib ! // ++++++++++++ process coOptions +++++++++++++++ ! string localDirectory = Environment.CurrentDirectory; workingDirectory = new WorkingDirectory( root, localDirectory, repository); // Create new CheckoutModuleCommand object getCommand = new CheckoutModuleCommand(workingDirectory); --- 175,186 ---- // create CvsRoot object parameter CvsRoot root = new CvsRoot(cocvsroot); ! if (localDirectory == null){ ! localDirectory = Environment.CurrentDirectory; ! } workingDirectory = new WorkingDirectory( root, localDirectory, repository); + if (revision != null){ + workingDirectory.Revision = revision; + } // Create new CheckoutModuleCommand object getCommand = new CheckoutModuleCommand(workingDirectory); |