use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class ModuleDefaultVcsRootPolicy method getDefaultVcsRoots.
@Override
@NotNull
public Collection<VirtualFile> getDefaultVcsRoots(@NotNull NewMappings mappingList, @NotNull String vcsName) {
Set<VirtualFile> result = newHashSet();
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
if (myBaseDir != null && vcsName.equals(mappingList.getVcsFor(myBaseDir))) {
final AbstractVcs vcsFor = vcsManager.getVcsFor(myBaseDir);
if (vcsFor != null && vcsName.equals(vcsFor.getName())) {
result.add(myBaseDir);
}
}
if (ProjectKt.isDirectoryBased(myProject) && myBaseDir != null) {
final VirtualFile ideaDir = ProjectKt.getStateStore(myProject).getDirectoryStoreFile();
if (ideaDir != null) {
final AbstractVcs vcsFor = vcsManager.getVcsFor(ideaDir);
if (vcsFor != null && vcsName.equals(vcsFor.getName())) {
result.add(ideaDir);
}
}
}
// assertion for read access inside
Module[] modules = ReadAction.compute(myModuleManager::getModules);
for (Module module : modules) {
final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile file : files) {
// if we're currently processing moduleAdded notification, getModuleForFile() will return null, so we pass the module
// explicitly (we know it anyway)
VcsDirectoryMapping mapping = mappingList.getMappingFor(file, module);
final String mappingVcs = mapping != null ? mapping.getVcs() : null;
if (vcsName.equals(mappingVcs) && file.isDirectory()) {
result.add(file);
}
}
}
return result;
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class ImportAction method createCheckoutAction.
private AbstractAction createCheckoutAction(final boolean makeNewFilesReadOnly) {
return new AbstractAction(false) {
protected String getTitle(VcsContext context) {
return CvsBundle.message("operation.name.check.out.project");
}
protected CvsHandler getCvsHandler(CvsContext context) {
final Project project = context.getProject();
return CommandCvsHandler.createCheckoutHandler(myImportDetails.getCvsRoot(), new String[] { myImportDetails.getModuleName() }, myImportDetails.getBaseImportDirectory(), true, makeNewFilesReadOnly, project == null ? null : VcsConfiguration.getInstance(project).getCheckoutOption());
}
protected void onActionPerformed(CvsContext context, CvsTabbedWindow tabbedWindow, boolean successfully, CvsHandler handler) {
super.onActionPerformed(context, tabbedWindow, successfully, handler);
final Project project = context.getProject();
if (successfully) {
if (project != null) {
final VirtualFile importedRoot = CvsVfsUtil.findFileByIoFile(myImportDetails.getBaseImportDirectory());
updateDirectoryMappings(project, importedRoot);
}
}
}
/**
* Basically copied from GitInit/HgInit
*/
private void updateDirectoryMappings(Project project, VirtualFile mapRoot) {
if (project == null || project.isDefault()) {
return;
}
final VirtualFile projectBaseDir = project.getBaseDir();
if (projectBaseDir == null || !VfsUtil.isAncestor(projectBaseDir, mapRoot, false)) {
return;
}
mapRoot.refresh(false, false);
final String path = mapRoot.equals(projectBaseDir) ? "" : mapRoot.getPath();
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, CvsVcs2.getInstance(project).getName()));
manager.updateActiveVcss();
}
};
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class BasicAction method collectAffectedFiles.
/**
* given a list of action-target files, returns ALL the files that should be
* subject to the action Does not keep directories, but recursively adds
* directory contents
*
* @param project the project subject of the action
* @param files the root selection
* @return the complete set of files this action should apply to
*/
@NotNull
protected VirtualFile[] collectAffectedFiles(@NotNull Project project, @NotNull VirtualFile[] files) {
List<VirtualFile> affectedFiles = new ArrayList<>(files.length);
ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project);
for (VirtualFile file : files) {
if (!file.isDirectory() && projectLevelVcsManager.getVcsFor(file) instanceof GitVcs) {
affectedFiles.add(file);
} else if (file.isDirectory() && isRecursive()) {
addChildren(project, affectedFiles, file);
}
}
return VfsUtilCore.toVirtualFileArray(affectedFiles);
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class HgTestUtil method updateDirectoryMappings.
public static void updateDirectoryMappings(Project project, VirtualFile mapRoot) {
if (project != null && (!project.isDefault()) && project.getBaseDir() != null && VfsUtilCore.isAncestor(project.getBaseDir(), mapRoot, false)) {
mapRoot.refresh(false, false);
final String path = mapRoot.equals(project.getBaseDir()) ? "" : mapRoot.getPath();
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, HgVcs.VCS_NAME));
}
}
Aggregations