private static SubversionArguments ReadCommandLineArguments(string[] args) { if (args.Length < 2 || args.Length > 3) { ShowHelp(); return(null); } int revision; if (!int.TryParse(args[1], out revision)) { ShowHelp(); Console.Error.WriteLine("Revision must be integer"); return(null); } string cwd = Directory.GetCurrentDirectory(); if (args.Length == 3) { cwd = args[2]; if (!Directory.Exists(cwd)) { ShowHelp(); Console.Error.WriteLine("Cwd doesn't exist"); return(null); } } var svnArgs = new SubversionArguments { RevisionTo = revision, Cwd = cwd, LocalProjectRootDirectory = FindProjectRootDirectory(cwd, ProjectSettings.DefaultFileName) }; try { #if TEST svnArgs.Message = DummyPatchCreator.GetMessageForRevision(svnArgs).Result; #else svnArgs.Message = SvnPatchCreator.GetMessageForRevision(svnArgs).Result; #endif } catch (Exception ex) { Console.Error.WriteLine("Unable to get message for revision: " + ex.Message); return(null); } return(svnArgs); }
private async void ButtonGoClick(object sender, EventArgs e) { int revisionTo; int revisionFrom = -1; if (string.IsNullOrWhiteSpace(textBoxProjectDirectory.Text) || !Directory.Exists(textBoxProjectDirectory.Text) || string.IsNullOrWhiteSpace(textBoxRevisionTo.Text) || !int.TryParse(textBoxRevisionTo.Text, out revisionTo) || (!string.IsNullOrWhiteSpace(textBoxRevisionFrom.Text) && !int.TryParse(textBoxRevisionFrom.Text, out revisionFrom)) || revisionFrom >= revisionTo ) { MessageBox.Show("Fill fields better"); return; } var cwd = textBoxProjectDirectory.Text; #if !TEST string projectRootDirectory; try { projectRootDirectory = Program.FindProjectRootDirectory(cwd, ProjectSettings.DefaultFileName); } catch { MessageBox.Show("Directory not gollum-compatible."); return; } #else const string projectRootDirectory = "C:\\"; #endif var subversionArguments = new SubversionArguments { RevisionTo = revisionTo, RevisionFrom = revisionFrom, Cwd = cwd, LocalProjectRootDirectory = projectRootDirectory }; buttonGo.Enabled = false; try { #if TEST subversionArguments.Message = await DummyPatchCreator.GetMessageForRevision(subversionArguments); ProjectSettings = new ProjectSettings { RepositoryBasePath = "/trunk", ReviewBoardGroup = "Ware", ReviewBoardRepositoryName = "Ware" }; #else subversionArguments.Message = await SvnPatchCreator.GetMessageForRevision(subversionArguments); ProjectSettings = ProjectSettings.Load(Path.Combine(subversionArguments.LocalProjectRootDirectory, ProjectSettings.DefaultFileName)); #endif SubversionArguments = subversionArguments; } catch (Exception ex) { MessageBox.Show("Unable to get message for revision: " + ex.Message); buttonGo.Enabled = true; return; } DialogResult = DialogResult.OK; Close(); }