public void StartCreateBranchDialog(string startingRevision, string defaultBranchName) { using (var dlg = new CreateBranchDialog(_repository)) { dlg.StartingRevision.Value = startingRevision; dlg.BranchName.Value = defaultBranchName; dlg.Run(_environment.MainForm); } }
public override void OnExecute(CommandEventArgs e) { SvnItem root = GetRoot(e); if (root == null) { return; } using (CreateBranchDialog dlg = new CreateBranchDialog()) { if (e.Command == AnkhCommand.ProjectBranch) { dlg.Text = CommandStrings.BranchProject; } dlg.SrcFolder = root.FullPath; dlg.SrcUri = root.Uri; dlg.EditSource = false; dlg.Revision = root.Status.Revision; RepositoryLayoutInfo info; if (RepositoryUrlUtils.TryGuessLayout(e.Context, root.Uri, out info)) { dlg.NewDirectoryName = new Uri(info.BranchesRoot, "."); } while (true) { if (DialogResult.OK != dlg.ShowDialog(e.Context)) { return; } string msg = dlg.LogMessage; bool retry = false; bool ok = false; ProgressRunnerResult rr = e.GetService <IProgressRunner>().RunModal(CommandStrings.CreatingBranch, delegate(object sender, ProgressWorkerArgs ee) { SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; if (ee.Client.Info(dlg.NewDirectoryName, ia, null)) { DialogResult dr = DialogResult.Cancel; ee.Synchronizer.Invoke((AnkhAction) delegate { AnkhMessageBox mb = new AnkhMessageBox(ee.Context); dr = mb.Show(string.Format("The Branch/Tag at Url '{0}' already exists.", dlg.NewDirectoryName), "Path Exists", MessageBoxButtons.RetryCancel); }, null); if (dr == DialogResult.Retry) { // show dialog again to let user modify the branch URL retry = true; } } else { SvnCopyArgs ca = new SvnCopyArgs(); ca.CreateParents = true; ca.LogMessage = msg; ok = dlg.CopyFromUri ? ee.Client.RemoteCopy(new SvnUriTarget(dlg.SrcUri, dlg.SelectedRevision), dlg.NewDirectoryName, ca) : ee.Client.RemoteCopy(dlg.SrcFolder, dlg.NewDirectoryName, ca); } }); if (rr.Succeeded && ok && dlg.SwitchToBranch) { e.GetService <IAnkhCommandService>().PostExecCommand(AnkhCommand.SolutionSwitchDialog, dlg.NewDirectoryName); } if (!retry) { break; } } } }