private bool ShouldIncludeInFilter(IVsHierarchyItem hierarchyItem)
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                if (hierarchyItem == null)
                {
                    return(false);
                }

                if (HierarchyUtilities.IsPhysicalFile(hierarchyItem.HierarchyIdentity) ||
                    HierarchyUtilities.IsProject(hierarchyItem.HierarchyIdentity))
                {
                    var absoluteFilePath = string.Empty;
                    if (HierarchyUtilities.IsPhysicalFile(hierarchyItem.HierarchyIdentity))
                    {
                        absoluteFilePath = hierarchyItem.CanonicalName;
                    }
                    else if (HierarchyUtilities.IsProject(hierarchyItem.HierarchyIdentity))
                    {
                        var vsHierarchy = hierarchyItem.HierarchyIdentity.Hierarchy;
                        vsHierarchy.ParseCanonicalName(hierarchyItem.CanonicalName, out uint itemId);
                        vsHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out object itemObject);
                        if (itemObject is EnvDTE.Project project)
                        {
                            absoluteFilePath = project.FullName;
                        }
                    }

                    if (!string.IsNullOrEmpty(absoluteFilePath))
                    {
                        DiffResultItem diffResultItem = this.branchDiffWorker.GetItemFromChangeSet(this.changeSet, absoluteFilePath);

                        if (diffResultItem != null)
                        {
                            // If the physical file in changeSet is under "External Dependencies" folder of a C++ project, always ignore. This file is a link, and already shows up elsewhere.
                            if (HierarchyUtilities.IsPhysicalFile(hierarchyItem.HierarchyIdentity) && IsCPPExternalDependencyFile(hierarchyItem))
                            {
                                return(false);
                            }

                            // Mark all Project nodes found in changeset, so we only enable "Open Diff With Base" button for these project nodes.
                            if (HierarchyUtilities.IsProject(hierarchyItem.HierarchyIdentity))
                            {
                                BranchDiffFilterProvider.TagManager.MarkProjAsChanged(hierarchyItem);
                            }

                            // If item renamed in working branch. Tag the old path so we find the Base branch version of file using the Old Path.
                            if (!string.IsNullOrEmpty(diffResultItem.OldAbsoluteFilePath))
                            {
                                BranchDiffFilterProvider.TagManager.SetOldFilePathOnRenamedItem(hierarchyItem, diffResultItem.OldAbsoluteFilePath);
                            }

                            return(true);
                        }
                    }
                }

                return(false);
            }
Exemplo n.º 2
0
            private bool ShouldIncludeInFilter(IVsHierarchyItem hierarchyItem)
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                if (hierarchyItem == null)
                {
                    return(false);
                }

                if (HierarchyUtilities.IsPhysicalFile(hierarchyItem.HierarchyIdentity) ||
                    HierarchyUtilities.IsProject(hierarchyItem.HierarchyIdentity))
                {
                    var absoluteFilePath = string.Empty;
                    if (HierarchyUtilities.IsPhysicalFile(hierarchyItem.HierarchyIdentity))
                    {
                        absoluteFilePath = hierarchyItem.CanonicalName;
                    }
                    else if (HierarchyUtilities.IsProject(hierarchyItem.HierarchyIdentity))
                    {
                        hierarchyItem.HierarchyIdentity.Hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out var prjObject);
                        if (prjObject is EnvDTE.Project project)
                        {
                            absoluteFilePath = project.FullName;
                        }
                    }

                    if (!string.IsNullOrEmpty(absoluteFilePath))
                    {
                        DiffResultItem diffResultItem = this.branchDiffWorker.GetItemFromChangeSet(this.changeSet, hierarchyItem.CanonicalName);

                        if (diffResultItem != null)
                        {
                            // Tag the old path so we find the Base branch version of file using the Old Path (for files renamed in the working branch)
                            if (!string.IsNullOrEmpty(diffResultItem.OldAbsoluteFilePath))
                            {
                                BranchDiffFilterProvider.TagManager.SetOldFilePathOnRenamedItem(
                                    hierarchyItem.HierarchyIdentity.Hierarchy,
                                    hierarchyItem.CanonicalName,
                                    diffResultItem.OldAbsoluteFilePath);
                            }

                            return(true);
                        }
                    }
                }

                return(false);
            }