public void TryGuessLayout_UNCFileTrunk_ReturnsBranches() { RepositoryLayoutInfo info; bool rslt = RepositoryUrlUtils.TryGuessLayout(new AnkhServiceProvider(), new Uri("file://server/share/repos/trunk/something"), out info); Assert.That(rslt); Assert.That(info.BranchesRoot, Is.EqualTo(new Uri("file://server/share/repos/branches/"))); }
public void TryGuessLayout_HttpTrunk_ReturnsBranches() { RepositoryLayoutInfo info; bool rslt = RepositoryUrlUtils.TryGuessLayout(new AnkhServiceProvider(), new Uri("http://server.tld/svn/trunk/something"), out info); Assert.That(rslt); Assert.That(info.BranchesRoot, Is.EqualTo(new Uri("http://server.tld/svn/branches/"))); }
public string GuessBranchOrTagName() { RepositoryLayoutInfo li; if (RepositoryUrlUtils.TryGuessLayout(Context, ProjectUri, out li)) { return(li.SelectedBranchName); } return(""); }
public void TestGuessLayoutFromNonStandardBranch() { Uri u = new Uri("http://svn.test.org/repos/myproj/sandbox/src/project.sln"); RepositoryLayoutInfo i; RepositoryUrlUtils.TryGuessLayout(new MockContext(), u, out i); Assert.IsNotNull(i, "expected a layout info"); Assert.AreEqual(new Uri("http://svn.test.org/repos/myproj/sandbox/"), i.WholeProjectRoot, "wrong project root"); Assert.AreEqual(new Uri("http://svn.test.org/repos/myproj/sandbox/src/"), i.WorkingRoot, "wrong working root"); Assert.AreEqual(new Uri("http://svn.test.org/repos/myproj/sandbox/branches/"), i.BranchesRoot, "wrong branch root"); Assert.AreEqual(new Uri("src/", UriKind.Relative), i.SelectedBranch, "wrong selected branch"); Assert.AreEqual("src", i.SelectedBranchName, "wrong selected name"); }
public void TestGuessLayoutComplexBranch() { Uri u = new Uri("http://svn.test.org/repos/project/branches/experimental/s/r/c/project.sln"); RepositoryLayoutInfo i; RepositoryUrlUtils.TryGuessLayout(new MockContext(), u, out i); Assert.IsNotNull(i, "expected a layout info"); Assert.AreEqual(new Uri("http://svn.test.org/repos/project/"), i.WholeProjectRoot, "wrong project root"); Assert.AreEqual(new Uri("http://svn.test.org/repos/project/branches/experimental/"), i.WorkingRoot, "wrong working root"); Assert.AreEqual(new Uri("http://svn.test.org/repos/project/branches/"), i.BranchesRoot, "wrong branch root"); Assert.AreEqual(new Uri("experimental/", UriKind.Relative), i.SelectedBranch, "wrong selected branch"); Assert.AreEqual("experimental", i.SelectedBranchName, "wrong selected name"); }
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; } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (checkOutFrom != null && RepositoryRootUri != null && ProjectUri != null) { checkOutFrom.Items.Clear(); Uri inner = ProjectTop ?? new Uri(ProjectUri, "./"); Uri info = RepositoryRootUri.MakeRelativeUri(inner); if (info.IsAbsoluteUri || info.ToString().StartsWith("../", StringComparison.Ordinal)) { RepositoryRootUri = new Uri(inner, "/"); } while (inner != RepositoryRootUri) { checkOutFrom.Items.Add(inner); inner = new Uri(inner, "../"); } checkOutFrom.Items.Add(inner); // Ok, let's find some sensible default // First use our generic guess algorithm as used by branching RepositoryLayoutInfo li; if (RepositoryUrlUtils.TryGuessLayout(Context, ProjectUri, out li)) { foreach (Uri uri in checkOutFrom.Items) { if (uri == li.WorkingRoot) { checkOutFrom.SelectedItem = uri; break; } } } if (checkOutFrom.SelectedIndex < 0) { foreach (Uri uri in checkOutFrom.Items) { string txt = uri.ToString(); if (txt.EndsWith("/trunk/", StringComparison.OrdinalIgnoreCase)) { checkOutFrom.SelectedItem = uri; break; } } } if (checkOutFrom.SelectedIndex < 0) { foreach (Uri uri in checkOutFrom.Items) { string txt = uri.ToString(); if (txt.EndsWith("/branches/", StringComparison.OrdinalIgnoreCase) || txt.EndsWith("/tags/", StringComparison.OrdinalIgnoreCase) || txt.EndsWith("/releases/", StringComparison.OrdinalIgnoreCase)) { int nIndex = checkOutFrom.Items.IndexOf(uri); if (nIndex > 1) { checkOutFrom.SelectedIndex = nIndex - 1; break; } } } } if (checkOutFrom.SelectedIndex < 0) { foreach (Uri uri in checkOutFrom.Items) { string txt = uri.ToString(); if (txt.EndsWith("/src/", StringComparison.OrdinalIgnoreCase) || txt.EndsWith("/source/", StringComparison.OrdinalIgnoreCase) || txt.EndsWith("/sourcecode/", StringComparison.OrdinalIgnoreCase)) { int nIndex = checkOutFrom.Items.IndexOf(uri); if (nIndex < checkOutFrom.Items.Count - 1) { checkOutFrom.SelectedIndex = nIndex + 1; break; } } } } if (checkOutFrom.SelectedIndex < 0 && checkOutFrom.Items.Count > 0) { checkOutFrom.SelectedIndex = 0; } version.Context = Context; } }