summaryrefslogtreecommitdiff
path: root/platform/vcs-impl/src/com/intellij/openapi/vcs/impl
diff options
context:
space:
mode:
Diffstat (limited to 'platform/vcs-impl/src/com/intellij/openapi/vcs/impl')
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java7
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java35
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java18
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java79
4 files changed, 73 insertions, 66 deletions
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
index 4f4efe5137a3..4b057f49b282 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
@@ -21,7 +21,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectEx;
@@ -35,7 +34,6 @@ import com.intellij.openapi.vcs.changes.FilePathUnderVcs;
import com.intellij.openapi.vcs.changes.VcsGuess;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.impl.projectlevelman.NewMappings;
-import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -102,10 +100,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
if (matchContext != null) {
return true;
}
- if (myBaseDir != null && VfsUtilCore.isAncestor(myBaseDir, file, false)) {
- return !ProjectRootManager.getInstance(myProject).getFileIndex().isIgnored(file);
- }
- return false;
+ return myBaseDir != null && VfsUtilCore.isAncestor(myBaseDir, file, false);
}
@Override
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
index cbf9d2b1889a..5cc3a8a9ca92 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
@@ -135,7 +135,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
myMappings = new NewMappings(myProject, myMessageBus, this, manager, excludedFileIndex);
myMappingsToRoots = new MappingsToRoots(myMappings, myProject);
- if (! myProject.isDefault()) {
+ if (!myProject.isDefault()) {
myVcsEventListenerManager = new VcsEventsListenerManagerImpl();
}
@@ -203,7 +203,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
}
public boolean haveVcses() {
- return ! AllVcses.getInstance(myProject).isEmpty();
+ return !AllVcses.getInstance(myProject).isEmpty();
}
@Override
@@ -356,7 +356,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
}
public void unregisterVcs(AbstractVcs vcs) {
- if (! ApplicationManager.getApplication().isUnitTestMode() && myMappings.haveActiveVcs(vcs.getName())) {
+ if (!ApplicationManager.getApplication().isUnitTestMode() && myMappings.haveActiveVcs(vcs.getName())) {
// unlikely
LOG.warn("Active vcs '" + vcs.getName() + "' is being unregistered. Remove from mappings first.");
}
@@ -391,7 +391,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
public boolean hasAnyMappings() {
- return ! myMappings.isEmpty();
+ return !myMappings.isEmpty();
}
@Override
@@ -452,7 +452,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
private void releaseEditor() {
if (myEditorAdapter != null) {
final Editor editor = myEditorAdapter.getEditor();
- if (! editor.isDisposed()) {
+ if (!editor.isDisposed()) {
EditorFactory.getInstance().releaseEditor(editor);
}
}
@@ -472,7 +472,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
@NotNull
public VcsShowSettingOption getStandardOption(@NotNull VcsConfiguration.StandardOption option, @NotNull AbstractVcs vcs) {
- final VcsShowOptionsSettingImpl options = (VcsShowOptionsSettingImpl) getOptions(option);
+ final VcsShowOptionsSettingImpl options = (VcsShowOptionsSettingImpl)getOptions(option);
options.addApplicableVcs(vcs);
return options;
}
@@ -490,7 +490,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
public UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo, boolean canceled) {
- if (! myProject.isOpen() || myProject.isDisposed()) return null;
+ if (!myProject.isOpen() || myProject.isDisposed()) return null;
ContentManager contentManager = getContentManager();
if (contentManager == null) {
return null; // content manager is made null during dispose; flag is set later
@@ -537,7 +537,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
public boolean hasExplicitMapping(final VirtualFile vFile) {
final VcsDirectoryMapping mapping = myMappings.getMappingFor(vFile);
- return mapping != null && ! mapping.isDefaultMapping();
+ return mapping != null && !mapping.isDefaultMapping();
}
@Override
@@ -687,7 +687,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
final AbstractVcs[] vcses = myMappings.getActiveVcses();
for (AbstractVcs vcs : vcses) {
final VirtualFile[] roots = getRootsUnderVcs(vcs);
- for(VirtualFile root: roots) {
+ for (VirtualFile root : roots) {
vcsRoots.add(new VcsRoot(vcs, root));
}
}
@@ -708,10 +708,8 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
myMappings.clear();
final List<VcsDirectoryMapping> mappingsList = new ArrayList<VcsDirectoryMapping>();
- final List list = element.getChildren(ELEMENT_MAPPING);
boolean haveNonEmptyMappings = false;
- for(Object childObj: list) {
- Element child = (Element) childObj;
+ for (Element child : element.getChildren(ELEMENT_MAPPING)) {
final String vcs = child.getAttributeValue(ATTRIBUTE_VCS);
if (vcs != null && !vcs.isEmpty()) {
haveNonEmptyMappings = true;
@@ -729,8 +727,9 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
try {
rootSettings.readExternal(rootSettingsElement);
mapping.setRootSettings(rootSettings);
- } catch (InvalidDataException e) {
- LOG.error("Failed to load VCS root settings class "+ className + " for VCS " + vcsInstance.getClass().getName(), e);
+ }
+ catch (InvalidDataException e) {
+ LOG.error("Failed to load VCS root settings class " + className + " for VCS " + vcsInstance.getClass().getName(), e);
}
}
}
@@ -748,7 +747,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
if (myProject.isDefault()) {
element.setAttribute(ATTRIBUTE_DEFAULT_PROJECT, Boolean.TRUE.toString());
}
- for(VcsDirectoryMapping mapping: getDirectoryMappings()) {
+ for (VcsDirectoryMapping mapping : getDirectoryMappings()) {
Element child = new Element(ELEMENT_MAPPING);
child.setAttribute(ATTRIBUTE_DIRECTORY, mapping.getDirectory());
child.setAttribute(ATTRIBUTE_VCS, mapping.getVcs());
@@ -803,7 +802,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
public void fireDirectoryMappingsChanged() {
- if (myProject.isOpen() && ! myProject.isDisposed()) {
+ if (myProject.isOpen() && !myProject.isDisposed()) {
myMappings.mappingsChanged();
}
}
@@ -844,7 +843,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
public Boolean compute() {
return vf != null && (myExcludedIndex.isInContent(vf) || isFileInBaseDir(vf) || vf.equals(myProject.getBaseDir()) ||
- hasExplicitMapping(vf) || isInDirectoryBasedRoot(vf)) && ! myExcludedIndex.isExcludedFile(vf);
+ hasExplicitMapping(vf) || isInDirectoryBasedRoot(vf)) && !myExcludedIndex.isExcludedFile(vf);
}
});
}
@@ -862,7 +861,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
private boolean isInDirectoryBasedRoot(final VirtualFile file) {
if (file == null) return false;
- final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
+ final StorageScheme storageScheme = ((ProjectEx)myProject).getStateStore().getStorageScheme();
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
final VirtualFile baseDir = myProject.getBaseDir();
if (baseDir == null) return false;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java
index 8caa6f2bc981..122988896cb2 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsRootIterator.java
@@ -54,12 +54,10 @@ public class VcsRootIterator {
public boolean acceptFolderUnderVcs(final VirtualFile vcsRoot, final VirtualFile file) {
final String vcsUrl = vcsRoot.getUrl();
final MyRootFilter rootFilter = myOtherVcsFolders.get(vcsUrl);
- if ((rootFilter != null) && (! rootFilter.accept(file))) {
+ if ((rootFilter != null) && (!rootFilter.accept(file))) {
return false;
}
- final Boolean excluded = isExcluded(myExcludedFileIndex, file);
- if (excluded) return false;
- return true;
+ return !isExcluded(myExcludedFileIndex, file);
}
private static boolean isExcluded(final FileIndexFacade indexFacade, final VirtualFile file) {
@@ -128,9 +126,9 @@ public class VcsRootIterator {
}
public static void iterateVcsRoot(final Project project,
- final VirtualFile root,
- final Processor<FilePath> processor,
- @Nullable VirtualFileFilter directoryFilter) {
+ final VirtualFile root,
+ final Processor<FilePath> processor,
+ @Nullable VirtualFileFilter directoryFilter) {
final MyRootIterator rootIterator = new MyRootIterator(project, root, processor, null, directoryFilter);
rootIterator.iterate();
}
@@ -177,9 +175,9 @@ public class VcsRootIterator {
@Override
public Result visitFileEx(@NotNull VirtualFile file) {
if (isExcluded(myExcludedFileIndex, file)) return SKIP_CHILDREN;
- if (myRootPresentFilter != null && ! myRootPresentFilter.accept(file)) return SKIP_CHILDREN;
- if (myProject.isDisposed() || ! process(file)) return skipTo(myRoot);
- if (myDirectoryFilter != null && file.isDirectory() && ! myDirectoryFilter.shouldGoIntoDirectory(file)) return SKIP_CHILDREN;
+ if (myRootPresentFilter != null && !myRootPresentFilter.accept(file)) return SKIP_CHILDREN;
+ if (myProject.isDisposed() || !process(file)) return skipTo(myRoot);
+ if (myDirectoryFilter != null && file.isDirectory() && !myDirectoryFilter.shouldGoIntoDirectory(file)) return SKIP_CHILDREN;
return CONTINUE;
}
});
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
index de1a40d80f36..32fe920fc4db 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
@@ -53,30 +53,31 @@ public class NewMappings {
private final DefaultVcsRootPolicy myDefaultVcsRootPolicy;
private final MessageBus myMessageBus;
private final FileStatusManager myFileStatusManager;
- private final FileIndexFacade myExcludedFileIndex;
+ private final FileIndexFacade myFileIndexFacade;
private final Project myProject;
private boolean myActivated;
public NewMappings(final Project project, final MessageBus messageBus,
- final ProjectLevelVcsManagerImpl vcsManager, FileStatusManager fileStatusManager, FileIndexFacade excludedFileIndex) {
+ final ProjectLevelVcsManagerImpl vcsManager, FileStatusManager fileStatusManager, FileIndexFacade fileIndexFacade) {
myProject = project;
myMessageBus = messageBus;
myFileStatusManager = fileStatusManager;
- myExcludedFileIndex = excludedFileIndex;
+ myFileIndexFacade = fileIndexFacade;
myLock = new Object();
myVcsToPaths = new HashMap<String, List<VcsDirectoryMapping>>();
myFileWatchRequestsManager = new FileWatchRequestsManager(myProject, this, LocalFileSystem.getInstance());
myDefaultVcsRootPolicy = DefaultVcsRootPolicy.getInstance(project);
myActiveVcses = new AbstractVcs[0];
- if (! myProject.isDefault()) {
+ if (!myProject.isDefault()) {
final ArrayList<VcsDirectoryMapping> listStr = new ArrayList<VcsDirectoryMapping>();
final VcsDirectoryMapping mapping = new VcsDirectoryMapping("", "");
listStr.add(mapping);
myVcsToPaths.put("", listStr);
- mySortedMappings = new VcsDirectoryMapping[] {mapping};
- } else {
+ mySortedMappings = new VcsDirectoryMapping[]{mapping};
+ }
+ else {
mySortedMappings = VcsDirectoryMapping.EMPTY_ARRAY;
}
myActivated = false;
@@ -131,7 +132,6 @@ public class NewMappings {
return;
}
}
-
}
final Ref<Boolean> switched = new Ref<Boolean>(Boolean.FALSE);
@@ -139,7 +139,7 @@ public class NewMappings {
public void run() {
// sorted -> map. sorted mappings are NOT changed;
switched.set(trySwitchVcs(path, activeVcsName));
- if (! switched.get().booleanValue()) {
+ if (!switched.get().booleanValue()) {
final List<VcsDirectoryMapping> newList = listForVcsFromMap(newMapping.getVcs());
newList.add(newMapping);
sortedMappingsByMap();
@@ -153,7 +153,7 @@ public class NewMappings {
private void keepActiveVcs(@NotNull Runnable runnable) {
final MyVcsActivator activator;
synchronized (myLock) {
- if (! myActivated) {
+ if (!myActivated) {
runnable.run();
return;
}
@@ -204,7 +204,8 @@ public class NewMappings {
final List<VcsDirectoryMapping> itemsCopy;
if (items.isEmpty()) {
itemsCopy = Collections.singletonList(new VcsDirectoryMapping("", ""));
- } else {
+ }
+ else {
itemsCopy = items;
}
@@ -224,7 +225,7 @@ public class NewMappings {
@Nullable
public VcsDirectoryMapping getMappingFor(@Nullable VirtualFile file) {
if (file == null) return null;
- if (! file.isInLocalFileSystem()) {
+ if (!file.isInLocalFileSystem()) {
return null;
}
@@ -232,17 +233,22 @@ public class NewMappings {
}
@Nullable
- public VcsDirectoryMapping getMappingFor(final VirtualFile file, final Object matchContext) {
+ public VcsDirectoryMapping getMappingFor(final VirtualFile file, final Object parentModule) {
+ // if parentModule is not null it means that file belongs to the module so it isn't excluded
+ if (parentModule == null && myFileIndexFacade.isExcludedFile(file)) {
+ return null;
+ }
+
// performance: calculate file path just once, rather than once per mapping
String path = file.getPath();
- final String systemIndependentPath = FileUtil.toSystemIndependentName((file.isDirectory() && (! path.endsWith("/"))) ? (path + "/") : path);
+ final String systemIndependentPath = FileUtil.toSystemIndependentName((file.isDirectory() && (!path.endsWith("/"))) ? (path + "/") : path);
final VcsDirectoryMapping[] mappings;
synchronized (myLock) {
mappings = mySortedMappings;
}
- for (int i = mappings.length - 1; i >= 0; -- i) {
+ for (int i = mappings.length - 1; i >= 0; --i) {
final VcsDirectoryMapping mapping = mappings[i];
- if (fileMatchesMapping(file, matchContext, systemIndependentPath, mapping)) {
+ if (fileMatchesMapping(file, parentModule, systemIndependentPath, mapping)) {
return mapping;
}
}
@@ -258,12 +264,14 @@ public class NewMappings {
return mapping.getVcs();
}
- private boolean fileMatchesMapping(final VirtualFile file, final Object matchContext, final String systemIndependentPath, final VcsDirectoryMapping mapping) {
+ private boolean fileMatchesMapping(final VirtualFile file,
+ final Object matchContext,
+ final String systemIndependentPath,
+ final VcsDirectoryMapping mapping) {
if (mapping.getDirectory().length() == 0) {
return myDefaultVcsRootPolicy.matchesDefaultMapping(file, matchContext);
}
- return FileUtil.startsWith(systemIndependentPath, mapping.systemIndependentPath()) &&
- ! myExcludedFileIndex.isExcludedFile(file);
+ return FileUtil.startsWith(systemIndependentPath, mapping.systemIndependentPath());
}
public List<VirtualFile> getMappingsAsFilesUnderVcs(final AbstractVcs vcs) {
@@ -281,7 +289,8 @@ public class NewMappings {
if (mapping.isDefaultMapping()) {
// todo callback here; don't like it
myDefaultVcsRootPolicy.addDefaultVcsRoots(this, vcsName, result);
- } else {
+ }
+ else {
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(mapping.getDirectory());
if (file != null) {
result.add(file);
@@ -307,7 +316,7 @@ public class NewMappings {
private void clearImpl() {
// if vcses were not mapped, there's nothing to clear
- if ((myActiveVcses == null) || (myActiveVcses.length == 0)) return;
+ if ((myActiveVcses == null) || (myActiveVcses.length == 0)) return;
keepActiveVcs(new Runnable() {
public void run() {
@@ -374,7 +383,7 @@ public class NewMappings {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final AllVcsesI allVcses = AllVcses.getInstance(myProject);
- for (Iterator<String> iterator = myVcsToPaths.keySet().iterator(); iterator.hasNext();) {
+ for (Iterator<String> iterator = myVcsToPaths.keySet().iterator(); iterator.hasNext(); ) {
final String vcsName = iterator.next();
final List<VcsDirectoryMapping> mappings = myVcsToPaths.get(vcsName);
@@ -399,8 +408,9 @@ public class NewMappings {
};
if (StringUtil.isEmptyOrSpaces(vcsName)) {
filteredFiles = AbstractVcs.filterUniqueRootsDefault(objects, fileConvertor);
- } else {
- final AbstractVcs vcs = allVcses.getByName(vcsName);
+ }
+ else {
+ final AbstractVcs<?> vcs = allVcses.getByName(vcsName);
if (vcs == null) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS plugin not found for mapping to : '" + vcsName + "'", MessageType.ERROR);
continue;
@@ -420,7 +430,8 @@ public class NewMappings {
if (filteredMappings.isEmpty()) {
iterator.remove();
- } else {
+ }
+ else {
mappings.clear();
mappings.addAll(filteredMappings);
}
@@ -434,7 +445,7 @@ public class NewMappings {
for (VcsDirectoryMapping mapping : mySortedMappings) {
if (mapping.systemIndependentPath().equals(fixedPath)) {
final String oldVcs = mapping.getVcs();
- if (! oldVcs.equals(activeVcsName)) {
+ if (!oldVcs.equals(activeVcsName)) {
migrateVcs(activeVcsName, mapping, oldVcs);
}
return true;
@@ -489,7 +500,7 @@ public class NewMappings {
return ourInstance;
}
- public int compare(VcsDirectoryMapping m1, VcsDirectoryMapping m2) {
+ public int compare(@NotNull VcsDirectoryMapping m1, @NotNull VcsDirectoryMapping m2) {
return m1.getDirectory().compareTo(m2.getDirectory());
}
}
@@ -514,7 +525,8 @@ public class NewMappings {
catch (VcsException e) {
// actually is not thrown (AbstractVcs#actualActivate())
}
- } else {
+ }
+ else {
LOG.info("Error: activating non existing vcs: " + s);
}
}
@@ -529,7 +541,8 @@ public class NewMappings {
catch (VcsException e) {
// actually is not thrown (AbstractVcs#actualDeactivate())
}
- } else {
+ }
+ else {
LOG.info("Error: removing non existing vcs: " + s);
}
}
@@ -543,7 +556,7 @@ public class NewMappings {
// omit empty vcs: not a vcs
if (topItem.trim().length() == 0) continue;
- if (! bottom.contains(topItem)) {
+ if (!bottom.contains(topItem)) {
if (notInBottom == null) {
notInBottom = new HashSet<String>();
}
@@ -589,7 +602,8 @@ public class NewMappings {
public void invoke() {
if (myItems.isEmpty()) {
myItemsCopy = Collections.singletonList(new VcsDirectoryMapping("", ""));
- } else {
+ }
+ else {
myItemsCopy = myItems;
}
}
@@ -606,8 +620,9 @@ public class NewMappings {
myDefaultVcsRootPolicy.addDefaultVcsRoots(this, defaultVcs, list);
if (StringUtil.isEmptyOrSpaces(defaultVcs)) {
return AbstractVcs.filterUniqueRootsDefault(list, Convertor.SELF);
- } else {
- final AbstractVcs vcs = AllVcses.getInstance(myProject).getByName(defaultVcs);
+ }
+ else {
+ final AbstractVcs<?> vcs = AllVcses.getInstance(myProject).getByName(defaultVcs);
if (vcs == null) {
return AbstractVcs.filterUniqueRootsDefault(list, Convertor.SELF);
}