IDEA-51905 (CVS: Update Project and Repository/Incoming views don't work if the VCS...
authorirengrig <Irina.Chernushina@jetbrains.com>
Fri, 5 Feb 2010 15:23:15 +0000 (18:23 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Fri, 5 Feb 2010 15:23:15 +0000 (18:23 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRootsHelper.java [new file with mode: 0644]

index 362237d397b712890750c91b1cb4a0afa689cd4f..2b7d5308b3c3828d26e474b038d4630982553472 100644 (file)
@@ -48,7 +48,7 @@ public class DescindingFilesFilter {
         result.add(root);
         continue;
       }
-      if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
+      //if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
       
       final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
       if (chain == null) {
index 6215b6a9d489b9d3c58ec6f100d70d3ad85c52a2..dd34b99dfddefecf1dda65526367873945b272bb 100644 (file)
@@ -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());
+  }
 }
index 4c158a59a9fc4bd65e74bc80f68f19c47de44370..25e323f596168b328bac1e63dc64212e4c4af5f4 100644 (file)
@@ -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 {
index dc3927799f19edf5accefa1644f501f01f498145..5a203d92569b4c0a3672d10768edc41ff31a4c33 100644 (file)
@@ -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 (file)
index 0000000..66447fc
--- /dev/null
@@ -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<FilePath> result = new ArrayList<FilePath>();
+
+    final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
+      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()]);
+  }
+}