use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class GithubShareAction method filterOutIgnored.
@NotNull
private static Collection<VirtualFile> filterOutIgnored(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
return ContainerUtil.filter(files, file -> !changeListManager.isIgnoredFile(file) && !vcsManager.isIgnored(file));
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class ExternalSystemVcsRegistrar method handle.
@SuppressWarnings("unchecked")
public static void handle(@NotNull final Project project) {
for (final ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
final AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project);
settings.subscribe(new ExternalSystemSettingsListenerAdapter() {
@Override
public void onProjectsLinked(@NotNull final Collection linked) {
List<VcsDirectoryMapping> newMappings = ContainerUtilRt.newArrayList();
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
for (Object o : linked) {
final ExternalProjectSettings settings = (ExternalProjectSettings) o;
VirtualFile dir = fileSystem.refreshAndFindFileByPath(settings.getExternalProjectPath());
if (dir == null) {
continue;
}
if (!dir.isDirectory()) {
dir = dir.getParent();
}
newMappings.addAll(VcsUtil.findRoots(dir, project));
}
// There is a possible case that no VCS mappings are configured for the current project. There is a single
// mapping like <Project> - <No VCS> then. We want to replace it if only one mapping to the project root dir
// has been detected then.
List<VcsDirectoryMapping> oldMappings = vcsManager.getDirectoryMappings();
if (oldMappings.size() == 1 && newMappings.size() == 1 && StringUtil.isEmpty(oldMappings.get(0).getVcs())) {
VcsDirectoryMapping newMapping = newMappings.iterator().next();
String detectedDirPath = newMapping.getDirectory();
VirtualFile detectedDir = fileSystem.findFileByPath(detectedDirPath);
if (detectedDir != null && detectedDir.equals(project.getBaseDir())) {
newMappings.clear();
newMappings.add(new VcsDirectoryMapping("", newMapping.getVcs()));
vcsManager.setDirectoryMappings(newMappings);
return;
}
}
newMappings.addAll(oldMappings);
vcsManager.setDirectoryMappings(newMappings);
}
});
}
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class DvcsUtil method addMappingIfSubRoot.
public static void addMappingIfSubRoot(@NotNull Project project, @NotNull String newRepositoryPath, @NotNull String vcsName) {
if (project.getBasePath() != null && FileUtil.isAncestor(project.getBasePath(), newRepositoryPath, true)) {
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), newRepositoryPath, vcsName));
}
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class VcsCherryPickAction method getActiveCherryPickersForProject.
@NotNull
private static List<VcsCherryPicker> getActiveCherryPickersForProject(@Nullable final Project project) {
if (project != null) {
final ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project);
AbstractVcs[] vcss = projectLevelVcsManager.getAllActiveVcss();
return ContainerUtil.mapNotNull(vcss, vcs -> vcs != null ? VcsCherryPickManager.getInstance(project).getCherryPickerFor(vcs.getKeyInstanceMethod()) : null);
}
return ContainerUtil.emptyList();
}
use of com.intellij.openapi.vcs.ProjectLevelVcsManager in project intellij-community by JetBrains.
the class VcsContentAnnotationImpl method intervalRecentlyChanged.
@Override
public boolean intervalRecentlyChanged(VirtualFile file, TextRange lineInterval, VcsRevisionNumber currentRevisionNumber) {
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
final AbstractVcs vcs = vcsManager.getVcsFor(file);
if (vcs == null || vcs.getDiffProvider() == null)
return false;
if (currentRevisionNumber == null) {
currentRevisionNumber = vcs.getDiffProvider().getCurrentRevision(file);
assert currentRevisionNumber != null;
}
final ThreeState isRecent = myContentAnnotationCache.isRecent(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, lineInterval, System.currentTimeMillis() - mySettings.getLimit());
if (!ThreeState.UNSURE.equals(isRecent))
return ThreeState.YES.equals(isRecent);
final FileAnnotation fileAnnotation;
try {
fileAnnotation = vcs.getAnnotationProvider().annotate(file);
} catch (VcsException e) {
LOG.info(e);
return false;
}
myContentAnnotationCache.register(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, fileAnnotation);
for (int i = lineInterval.getStartOffset(); i <= lineInterval.getEndOffset(); i++) {
Date lineDate = fileAnnotation.getLineDate(i);
if (lineDate != null && isRecent(lineDate))
return true;
}
return false;
}
Aggregations