vcs: don't scan for vcs roots of content roots, which are under project dir

If a content root is located inside the project base dir, its roots will already be scanned.
On the other hand, if there are a lot of modules, scanning each of it produces a lot of extra work.

Relates to IDEA-174636
This commit is contained in:
Kirill Likhodedov
2018-06-09 10:42:18 +03:00
parent f042e70b7a
commit 80a4d348a8
@@ -26,6 +26,7 @@ import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsRoot; import com.intellij.openapi.vcs.VcsRoot;
import com.intellij.openapi.vcs.VcsRootChecker; import com.intellij.openapi.vcs.VcsRootChecker;
import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import one.util.streamex.StreamEx; import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -78,8 +79,10 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
Set<VcsRoot> vcsRoots = new HashSet<>(); Set<VcsRoot> vcsRoots = new HashSet<>();
if (myProject.isDisposed()) return vcsRoots; if (myProject.isDisposed()) return vcsRoots;
VirtualFile[] roots = myProjectManager.getContentRoots(); for (VirtualFile contentRoot : myProjectManager.getContentRoots()) {
for (VirtualFile contentRoot : roots) { if (myProject.getBaseDir() != null && VfsUtilCore.isAncestor(myProject.getBaseDir(), contentRoot, false)) {
continue;
}
Set<VcsRoot> rootsInsideRoot = scanForRootsInsideDir(contentRoot); Set<VcsRoot> rootsInsideRoot = scanForRootsInsideDir(contentRoot);
boolean shouldScanAbove = true; boolean shouldScanAbove = true;