use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class AbstractShowDiffAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
Project project = assertNotNull(vcsContext.getProject());
if (!ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + vcsContext.getActionName() + " now")) {
VirtualFile file = vcsContext.getSelectedFiles()[0];
AbstractVcs vcs = assertNotNull(ChangesUtil.getVcsForFile(file, project));
DiffProvider provider = assertNotNull(vcs.getDiffProvider());
getExecutor(provider, file, project).showDiff();
}
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class IgnoredFilesCompositeHolder method cleanAndAdjustScope.
@Override
public void cleanAndAdjustScope(VcsModifiableDirtyScope scope) {
final AbstractVcs vcs = scope.getVcs();
if (myVcsIgnoredHolderMap.containsKey(vcs)) {
myVcsIgnoredHolderMap.get(vcs).cleanAndAdjustScope(scope);
}
myIdeIgnoredFilesHolder.cleanAndAdjustScope(scope);
}
use of com.intellij.openapi.vcs.AbstractVcs 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.AbstractVcs in project intellij-community by JetBrains.
the class ModuleVcsDetector method autoDetectModuleVcsMapping.
private void autoDetectModuleVcsMapping(final Module module) {
boolean mappingsUpdated = false;
final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile file : files) {
AbstractVcs vcs = myVcsManager.findVersioningVcs(file);
if (vcs != null && vcs != myVcsManager.getVcsFor(file)) {
myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName());
mappingsUpdated = true;
}
}
if (mappingsUpdated) {
myVcsManager.cleanupMappings();
}
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class AllVcses method getByName.
public AbstractVcs getByName(final String name) {
synchronized (myLock) {
final AbstractVcs vcs = myVcses.get(name);
if (vcs != null) {
return vcs;
}
}
// unmodifiable map => no sync needed
final VcsEP ep = myExtensions.get(name);
if (ep == null) {
return null;
}
// VcsEP guarantees to always return the same vcs value
final AbstractVcs vcs1 = ep.getVcs(myProject);
LOG.assertTrue(vcs1 != null, name);
synchronized (myLock) {
if (!myVcses.containsKey(name)) {
addVcs(vcs1);
}
return vcs1;
}
}
Aggregations