use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class LocalChangesUnderRoots method getRootForPath.
@Nullable
private VirtualFile getRootForPath(@NotNull FilePath file, @NotNull Collection<VirtualFile> rootsToSave) {
final VirtualFile vf = ChangesUtil.findValidParentUnderReadAction(file);
if (vf == null) {
return null;
}
VirtualFile rootCandidate = null;
for (VcsRoot root : myRoots) {
if (VfsUtilCore.isAncestor(root.getPath(), vf, false)) {
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.getPath(), true)) {
// in the case of nested roots choose the closest root
rootCandidate = root.getPath();
}
}
}
if (!rootsToSave.contains(rootCandidate))
return null;
return rootCandidate;
}
use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class VcsLogManager method findLogProviders.
@NotNull
public static Map<VirtualFile, VcsLogProvider> findLogProviders(@NotNull Collection<VcsRoot> roots, @NotNull Project project) {
Map<VirtualFile, VcsLogProvider> logProviders = ContainerUtil.newHashMap();
VcsLogProvider[] allLogProviders = Extensions.getExtensions(VcsLogProvider.LOG_PROVIDER_EP, project);
for (VcsRoot root : roots) {
AbstractVcs vcs = root.getVcs();
VirtualFile path = root.getPath();
if (vcs == null || path == null) {
LOG.error("Skipping invalid VCS root: " + root);
continue;
}
for (VcsLogProvider provider : allLogProviders) {
if (provider.getSupportedVcs().equals(vcs.getKeyInstanceMethod())) {
logProviders.put(path, provider);
break;
}
}
}
return logProviders;
}
use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class CvsCheckinHandlerFactory method createVcsHandler.
@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
return new CheckinHandler() {
@Nullable
public RefreshableOnComponent getAfterCheckinConfigurationPanel(Disposable parentDisposable) {
final Project project = panel.getProject();
final CvsVcs2 cvs = CvsVcs2.getInstance(project);
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
final Collection<VirtualFile> roots = panel.getRoots();
final Collection<FilePath> files = new HashSet<>();
for (VirtualFile root : roots) {
final VcsRoot vcsRoot = vcsManager.getVcsRootObjectFor(root);
if (vcsRoot == null || vcsRoot.getVcs() != cvs) {
continue;
}
files.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
}
return new AdditionalOptionsPanel(CvsConfiguration.getInstance(project), files, project);
}
};
}
use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class VcsRootDetectorImpl method scanForRootsInContentRoots.
@NotNull
private Set<VcsRoot> scanForRootsInContentRoots() {
Set<VcsRoot> vcsRoots = new HashSet<>();
if (myProject.isDisposed())
return vcsRoots;
VirtualFile[] roots = myProjectManager.getContentRoots();
for (VirtualFile contentRoot : roots) {
Set<VcsRoot> rootsInsideRoot = scanForRootsInsideDir(contentRoot);
boolean shouldScanAbove = true;
for (VcsRoot root : rootsInsideRoot) {
if (contentRoot.equals(root.getPath())) {
shouldScanAbove = false;
}
}
if (shouldScanAbove) {
List<VcsRoot> rootsAbove = scanForSingleRootAboveDir(contentRoot);
rootsInsideRoot.addAll(rootsAbove);
}
vcsRoots.addAll(rootsInsideRoot);
}
return vcsRoots;
}
use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class VcsRootDetectorImpl method scanForRootsInsideDir.
@NotNull
private Set<VcsRoot> scanForRootsInsideDir(@NotNull final VirtualFile dir, final int depth) {
LOG.debug("Scanning inside [" + dir + "], depth = " + depth);
final Set<VcsRoot> roots = new HashSet<>();
if (depth > MAXIMUM_SCAN_DEPTH) {
// performance optimization via limitation: don't scan deep though the whole VFS, 2 levels under a content root is enough
return roots;
}
if (myProject.isDisposed() || !dir.isDirectory()) {
return roots;
}
List<AbstractVcs> vcsList = getVcsListFor(dir);
LOG.debug("Found following VCSs: " + vcsList);
for (AbstractVcs vcs : vcsList) {
roots.add(new VcsRoot(vcs, dir));
}
for (VirtualFile child : dir.getChildren()) {
roots.addAll(scanForRootsInsideDir(child, depth + 1));
}
return roots;
}
Aggregations