From 83478df38e9c1f0292dd09d5cfa42c7c568697c0 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 5 Feb 2010 18:23:15 +0300 Subject: [PATCH] IDEA-51905 (CVS: Update Project and Repository/Incoming views don't work if the VCS rooot is set to , but the project root itself doesn't contain CVS admin files), reverts of checks made for other VCSes; fix of Clear Case thinking new modules are under CC --- .../openapi/vcs/actions/DescindingFilesFilter.java | 2 +- .../vcs/impl/ProjectLevelVcsManagerImpl.java | 24 +++++++++- .../vcs/impl/projectlevelman/MappingsToRoots.java | 3 +- .../cvsSupport2/cvshandlers/UpdateHandler.java | 4 +- .../cvsoperations/common/FindAllRootsHelper.java | 52 ++++++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRootsHelper.java diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java index 362237d397..2b7d5308b3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java @@ -48,7 +48,7 @@ public class DescindingFilesFilter { result.add(root); continue; } - if (pathsFilter != null && (! pathsFilter.convert(new Pair(root, vcs)))) continue; + //if (pathsFilter != null && (! pathsFilter.convert(new Pair(root, vcs)))) continue; final List chain = chains.get(vcs.getKeyInstanceMethod()); if (chain == null) { 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 6215b6a9d4..dd34b99dfd 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 @@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.impl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ProjectComponent; +import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.DisposableEditorPanel; import com.intellij.openapi.editor.Editor; @@ -27,8 +28,8 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.DumbAwareRunnable; -import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; @@ -636,4 +637,25 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme } }); } + + public boolean isFileInContent(final VirtualFile vf) { + final ExcludedFileIndex excludedIndex = ExcludedFileIndex.getInstance(myProject); + return (vf != null) && (excludedIndex.isInContent(vf) || isFileInBaseDir(vf) || vf.equals(myProject.getBaseDir()) || + hasExplicitMapping(vf) || isInDirectoryBasedRoot(vf)) && (! excludedIndex.isExcludedFile(vf)); + } + + private boolean isInDirectoryBasedRoot(final VirtualFile file) { + if (file == null) return false; + final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); + if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + final VirtualFile ideaDir = myProject.getBaseDir().findChild(Project.DIRECTORY_STORE_FOLDER); + return (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtil.isAncestor(ideaDir, file, false)); + } + return false; + } + + private boolean isFileInBaseDir(final VirtualFile file) { + VirtualFile parent = file.getParent(); + return !file.isDirectory() && parent != null && parent.equals(myProject.getBaseDir()); + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java index 4c158a59a9..25e323f596 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java @@ -48,7 +48,8 @@ public class MappingsToRoots { while(i < result.size()) { final VirtualFile previous = result.get(i - 1); final VirtualFile current = result.get(i); - if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(previous, current) && vcs.isVersionedDirectory(previous)) { + if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(previous, current)) { +// if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(previous, current) && vcs.isVersionedDirectory(previous)) { result.remove(i); } else { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java index dc3927799f..5a203d9256 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java @@ -22,6 +22,7 @@ import com.intellij.cvsSupport2.config.CvsConfiguration; import com.intellij.cvsSupport2.connections.CvsRootProvider; import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.cvsoperations.common.FindAllRoots; +import com.intellij.cvsSupport2.cvsoperations.common.FindAllRootsHelper; import com.intellij.cvsSupport2.cvsoperations.common.PostCvsActivity; import com.intellij.cvsSupport2.cvsoperations.cvsUpdate.MergedWithConflictProjectOrModuleFile; import com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation; @@ -74,7 +75,8 @@ public class UpdateHandler extends CommandCvsHandler implements PostCvsActivity try { super.beforeLogin(); FindAllRoots findAllRoots = new FindAllRoots(myProject); - myRoots.addAll(findAllRoots.executeOn(myFiles)); + final FilePath[] filteredFiles = FindAllRootsHelper.findVersionedUnder(myFiles); + myRoots.addAll(findAllRoots.executeOn(filteredFiles)); myNotProcessedRepositories.addAll(findAllRoots.getDirectoriesToBeUpdated()); myDirectoriesToBeProcessedCount = myNotProcessedRepositories.size(); for(VirtualFile file: myRoots) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRootsHelper.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRootsHelper.java new file mode 100644 index 0000000000..66447fceee --- /dev/null +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRootsHelper.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.cvsSupport2.cvsoperations.common; + +import com.intellij.cvsSupport2.CvsUtil; +import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.FilePathImpl; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.Processor; + +import java.util.ArrayList; +import java.util.List; + +public class FindAllRootsHelper { + private FindAllRootsHelper() { + } + + public static FilePath[] findVersionedUnder(final FilePath[] roots) { + final List result = new ArrayList(); + + final Processor processor = new Processor() { + public boolean process(VirtualFile file) { + final boolean underCvs = CvsUtil.fileIsUnderCvs(file); + if (underCvs) { + result.add(new FilePathImpl(file)); + } + return ! underCvs; + } + }; + + for (FilePath root : roots) { + final VirtualFile vf = root.getVirtualFile(); + if (vf == null) continue; + VfsUtil.processFilesRecursively(vf, processor); + } + return result.toArray(new FilePath[result.size()]); + } +} -- 2.11.4.GIT