private void dirUpButton_Click(object sender, EventArgs e) { Uri uri; if (Uri.TryCreate(urlBox.Text.Trim(), UriKind.Absolute, out uri)) { Uri parentUri = new Uri(uri, "../"); if (parentUri == uri || _repositoryRoots.Contains(uri)) { return; } Uri fileUri; string fileText = fileNameBox.Text.Trim(); if (!string.IsNullOrEmpty(fileText) && Uri.TryCreate(fileText.Trim(), UriKind.Relative, out fileUri)) { fileUri = parentUri.MakeRelativeUri(SvnTools.AppendPathSuffix(uri, fileText.Trim())); fileNameBox.Text = fileUri.ToString(); } SetDirectory(parentUri); RefreshBox(parentUri); } }
void ProcessOk() { UpdateDirectories(); string fileText = fileNameBox.Text; if (string.IsNullOrEmpty(fileText)) { return; } Uri dirUri; Uri fileUri; if (Uri.TryCreate(urlBox.Text, UriKind.Absolute, out dirUri) && Uri.TryCreate(fileText, UriKind.Relative, out fileUri)) { Uri combined = SvnTools.AppendPathSuffix(dirUri, SvnTools.UriPartToPath(fileText)); AnkhAction fill = delegate() { CheckResult(combined); }; fill.BeginInvoke(null, null); } }
public PathListViewItem(LogChangedPathsView view, ISvnLogItem logItem, SvnChangeItem change, Uri reposRoot, bool isInSelection, Color[] colorInfo) : base(view) { if (logItem == null) { throw new ArgumentNullException("logItem"); } if (change == null) { throw new ArgumentNullException("change"); } _logItem = logItem; _change = change; _isInSelection = isInSelection; Uri uri; string path = change.Path.TrimStart('/'); if (string.IsNullOrEmpty(path)) { uri = reposRoot; } else { uri = SvnTools.AppendPathSuffix(reposRoot, path); } _origin = new SvnOrigin(new SvnUriTarget(uri, logItem.Revision), reposRoot); RefreshText(); UpdateColors(colorInfo); }
internal void DoCreateDirectory() { RepositoryTreeNode tn = SelectedNode; if (tn == null) { return; } Uri u = tn.RawUri; using (Ankh.UI.SccManagement.CreateDirectoryDialog dialog = new Ankh.UI.SccManagement.CreateDirectoryDialog()) { if (dialog.ShowDialog(Context) != DialogResult.OK) { return; } Uri newDir = SvnTools.AppendPathSuffix(u, dialog.NewDirectoryName); Context.GetService <IProgressRunner>().RunModal( RepositoryStrings.CreatingDirectory, delegate(object sender, ProgressWorkerArgs a) { SvnCreateDirectoryArgs args = new SvnCreateDirectoryArgs(); args.CreateParents = true; args.LogMessage = dialog.LogMessage; a.Client.RemoteCreateDirectory(newDir, args); }); AddRoot(newDir); } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem selected = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); string directoryName = ""; using (CreateDirectoryDialog dlg = new CreateDirectoryDialog()) { DialogResult result = dlg.ShowDialog(e.Context); directoryName = dlg.NewDirectoryName; if (result != DialogResult.OK || string.IsNullOrEmpty(directoryName)) { return; } string log = dlg.LogMessage; // Handle special characters like on local path Uri uri = SvnTools.AppendPathSuffix(selected.Uri, directoryName); ProgressRunnerResult prResult = e.GetService <IProgressRunner>().RunModal( CommandStrings.CreatingDirectories, delegate(object sender, ProgressWorkerArgs ee) { SvnCreateDirectoryArgs args = new SvnCreateDirectoryArgs(); args.ThrowOnError = false; args.CreateParents = true; args.LogMessage = log; ee.Client.RemoteCreateDirectory(uri, args); } ); if (prResult.Succeeded) { selected.RefreshItem(false); } } }
void UpdateDirectories() { Uri nameUri; Uri dirUri; string urlBoxText = urlBox.Text; // Url's can not contain whitespace if (string.IsNullOrEmpty(urlBoxText) || !Uri.TryCreate(urlBoxText, UriKind.Absolute, out dirUri)) { dirUri = null; urlBox.Text = ""; } string name = fileNameBox.Text.Trim(); if (!string.IsNullOrEmpty(name) && Uri.TryCreate(name, UriKind.RelativeOrAbsolute, out nameUri)) { if (dirUri != null && !nameUri.IsAbsoluteUri && nameUri.ToString().Contains("/") || (nameUri.ToString() == "..")) { nameUri = SvnTools.AppendPathSuffix(dirUri, name); } if (nameUri.IsAbsoluteUri) { // We have an absolute url. Split it in file and directory string path = nameUri.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped); int dirEnd = path.LastIndexOf('/'); if (dirEnd >= 0) { path = path.Substring(0, dirEnd + 1); string v = nameUri.GetComponents(UriComponents.StrongAuthority | UriComponents.SchemeAndServer, UriFormat.SafeUnescaped); Uri uriRoot = new Uri(v); if (uriRoot.IsFile) { path = path.TrimStart('/'); // Fixup for UNC paths } Uri dir = new Uri(uriRoot, path); if (dir != nameUri) { nameUri = dir.MakeRelativeUri(nameUri); } else { nameUri = new Uri("", UriKind.Relative); } SetDirectory(dir); fileNameBox.Text = nameUri.ToString(); RefreshBox(dir); } } else if (dirUri == null) { return; } } }