// This common method used for both folders and files places the item in the SubItems list // of the appropriate parent folder, and also adds the item to the directSubItems list to be // returned on this call if and only if item is a direct child of the folderDiffItem argument // of GetFolderSubDiffItems(). private void ProcessSubItem( TfsVCDiffItem tfsDiffItem, TfsVCDiffItem topFolderDiffItem, List <IVCDiffItem> directSubItems, bool addSubItemToContainingFolderItem) { string containingFolderPath = VersionControlPath.GetFolderName(tfsDiffItem.ServerPath); if (addSubItemToContainingFolderItem) { TfsVCDiffItem containingFolderItem; if (!m_cachedFolderItems.TryGetValue(containingFolderPath, out containingFolderItem)) { TraceManager.TraceWarning(String.Format(CultureInfo.InvariantCulture, TfsVCAdapterResource.ContainingFolderNotFound, tfsDiffItem.ServerPath)); return; } containingFolderItem.SubItems.Add(tfsDiffItem); } if (string.Equals(topFolderDiffItem.ServerPath, containingFolderPath, StringComparison.InvariantCultureIgnoreCase)) { directSubItems.Add(tfsDiffItem); } }
internal static void OpenSolutionWithWorkspace(Workspace workspace, string serverItem, VersionSpec spec) { serverItem = VersionControlPath.GetFullPath(serverItem); WorkingFolder folderForServerItem1; try { folderForServerItem1 = workspace.TryGetWorkingFolderForServerItem(serverItem); } catch (Exception ex) { Output.Exception(ex); return; } if (folderForServerItem1 != null) { if (folderForServerItem1.IsCloaked) { int num1 = (int)Error(UIHost.DefaultParentWindow, GuiResources.Format("SolutionIsCloaked", (object)VersionControlPath.GetFileName(serverItem)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { try { VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem1.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version); } catch (Exception ex) { Output.Exception(ex); } } } else { string folderName = VersionControlPath.GetFolderName(serverItem); using (var dialogSetLocalFolder = (Form)TeamControlFactory.CreateDialogSetLocalFolder(workspace, folderName)) { if (UIHost.ShowModalDialog((Form)dialogSetLocalFolder) != DialogResult.OK) { return; } } try { WorkingFolder folderForServerItem2 = workspace.GetWorkingFolderForServerItem(serverItem); VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem2.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version); } catch (Exception ex) { Output.Exception(ex); } } }
internal static string GetOriginalName(PendingChange pendingChange, bool useServerPath) { string x = null; var itemName = GetItemName(pendingChange, useServerPath); if (!string.IsNullOrEmpty(pendingChange.SourceLocalItem) && !string.IsNullOrEmpty(pendingChange.LocalItem)) { x = FileSpec.GetFileName(pendingChange.SourceLocalItem); if ( !FileSpec.Equals(FileSpec.GetDirectoryName(pendingChange.SourceLocalItem), FileSpec.GetDirectoryName(pendingChange.LocalItem))) { x = pendingChange.SourceLocalItem; } if (string.Equals(x, itemName, StringComparison.Ordinal)) { x = null; } } if (x == null && !string.IsNullOrEmpty(pendingChange.SourceServerItem) && !string.IsNullOrEmpty(pendingChange.ServerItem)) { x = VersionControlPath.GetFileName(pendingChange.SourceServerItem); if ( !VersionControlPath.Equals(VersionControlPath.GetFolderName(pendingChange.SourceServerItem), VersionControlPath.GetFolderName(pendingChange.ServerItem))) { x = pendingChange.SourceServerItem; } if (string.Equals(x, itemName, StringComparison.Ordinal)) { x = null; } } return(x); }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (e.Cancel) { return; } string[] queryItems = (string[])e.Argument; ItemSpec[] array = new ItemSpec[queryItems.Length]; for (int i = 0; i < queryItems.Length; i++) { array[i] = new ItemSpec(VersionControlPath.Combine(queryItems[i], "*"), RecursionType.OneLevel); } ExtendedItem[][] itemSets; itemSets = m_workspace.GetExtendedItems(array, m_deletedState, ShowFiles ? ItemType.Any : ItemType.Folder, GetItemsOptions.IncludeBranchInfo); TempItemSet[] result = new TempItemSet[itemSets.Length]; for (int i = 0; i < itemSets.Length; i++) { result[i] = new TempItemSet { QueryPath = VersionControlPath.GetFolderName(array[i].Item), Items = itemSets[i].Where((item) => (item.TargetServerItem != queryItems[i] && (item.IsInWorkspace || !m_limitToWorkspace))).ToArray() }; } if (m_limitToWorkspace) { Workspace ws = m_workspace; ws.RefreshIfNeeded(); var folders = ws.Folders; foreach (TempItemSet its in result) { int desiredCloakDepth = VersionControlPath.GetFolderDepth(its.QueryPath) + 1; string cloakedWeSaw = null; List <ItemSpec> newItems = new List <ItemSpec>(); foreach (var fldr in folders) { if (fldr.IsCloaked && fldr.Depth != RecursionType.None && VersionControlPath.IsSubItem(fldr.ServerItem, its.QueryPath) && VersionControlPath.GetFolderDepth(fldr.ServerItem) == desiredCloakDepth) { cloakedWeSaw = fldr.ServerItem; } else if (!fldr.IsCloaked && cloakedWeSaw != null && VersionControlPath.IsSubItem(fldr.ServerItem, cloakedWeSaw)) { //we need this to keep going even if it's cloaked newItems.Add(new ItemSpec(cloakedWeSaw, RecursionType.None)); cloakedWeSaw = null; } } if (newItems.Count > 0) { ExtendedItem[] newExItems = new ExtendedItem[its.Items.Length + newItems.Count]; Array.Copy(its.Items, newExItems, its.Items.Length); ExtendedItem[][] tempExItems = m_sourceControl.GetExtendedItems(newItems.ToArray(), m_deletedState, ItemType.Folder, GetItemsOptions.IncludeBranchInfo); for (int i = 0; i < tempExItems.Length; i++) { newExItems[i + its.Items.Length] = tempExItems[i][0]; } its.Items = newExItems; } } } foreach (TempItemSet its in result) { Array.Sort(its.Items, (a, b) => a.TargetServerItem.CompareTo(b.TargetServerItem)); } e.Result = result; }