IDEA-51905 (CVS: Update Project and Repository/Incoming views don't work if the VCS...
authorirengrig <Irina.Chernushina@jetbrains.com>
Mon, 1 Feb 2010 07:13:49 +0000 (10:13 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Mon, 1 Feb 2010 07:13:49 +0000 (10:13 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractVcsAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java

index 1467ab6584eda7ccf2287b08387565d61f59f350..57a3a3b518af0786eee31fe4a9143997f6ef7412 100644 (file)
@@ -19,17 +19,16 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.AsyncUpdateAction;
 import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.AbstractVcs;
 import com.intellij.openapi.vcs.FilePath;
 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
-import com.intellij.openapi.vcs.VcsKey;
-import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.util.containers.HashSet;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
 
 public abstract class AbstractVcsAction extends AsyncUpdateAction<VcsContext> implements DumbAware {
   public static Collection<AbstractVcs> getActiveVcses(VcsContext dataContext) {
@@ -43,7 +42,7 @@ public abstract class AbstractVcsAction extends AsyncUpdateAction<VcsContext> im
 
   @NotNull
   protected static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
-    return DescindingFilesFilter.filterDescindingFiles(roots, project);
+    return DescindingFilesFilter.filterDescindingFiles(roots, project, null);
   }
 
   protected VcsContext prepareDataFromContext(final AnActionEvent e) {
index 092be3c0e4e4a1c21ccf5833a5a395a8aaa4565a..362237d397b712890750c91b1cb4a0afa689cd4f 100644 (file)
 package com.intellij.openapi.vcs.actions;
 
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vcs.AbstractVcs;
 import com.intellij.openapi.vcs.FilePath;
 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
 import com.intellij.openapi.vcs.VcsKey;
 import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.util.containers.Convertor;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.util.*;
 
@@ -30,7 +33,8 @@ public class DescindingFilesFilter {
   }
 
   @NotNull
-  public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
+  public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project,
+                                                 @Nullable final Convertor<Pair<FilePath, AbstractVcs>, Boolean> pathsFilter) {
     final List<FilePath> result = new LinkedList<FilePath>();
     ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
 
@@ -44,6 +48,8 @@ public class DescindingFilesFilter {
         result.add(root);
         continue;
       }
+      if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
+      
       final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
       if (chain == null) {
         final LinkedList<FilePath> newList = new LinkedList<FilePath>();
index e0088ca7f94644164bc5b62d3301acf5f7352541..4c158a59a9fc4bd65e74bc80f68f19c47de44370 100644 (file)
@@ -46,7 +46,9 @@ public class MappingsToRoots {
     if (! vcs.allowsNestedRoots()) {
       int i=1;
       while(i < result.size()) {
-        if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(result.get(i-1), result.get(i))) {
+        final VirtualFile previous = result.get(i - 1);
+        final VirtualFile current = result.get(i);
+        if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(previous, current) && vcs.isVersionedDirectory(previous)) {
           result.remove(i);
         }
         else {
index f227b677890702c4f13d42c0fa0924ab7f7ef4a7..4f5b2a9470b9a9795e9d084599b34fcff09ab905 100644 (file)
@@ -31,9 +31,11 @@ import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ex.ProjectManagerEx;
 import com.intellij.openapi.ui.MessageType;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.vcs.*;
 import com.intellij.openapi.vcs.actions.AbstractVcsAction;
+import com.intellij.openapi.vcs.actions.DescindingFilesFilter;
 import com.intellij.openapi.vcs.actions.VcsContext;
 import com.intellij.openapi.vcs.changes.RemoteRevisionsCache;
 import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
@@ -48,6 +50,7 @@ import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.util.containers.Convertor;
 import com.intellij.util.messages.MessageBusConnection;
 import com.intellij.util.ui.OptionsDialog;
 import com.intellij.vcsUtil.VcsUtil;
@@ -81,7 +84,14 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
     if (project != null) {
       try {
         final FilePath[] filePaths = myScopeInfo.getRoots(context, myActionInfo);
-        final FilePath[] roots = filterDescindingFiles(filterRoots(filePaths, context), project);
+        final FilePath[] roots = DescindingFilesFilter.filterDescindingFiles(filterRoots(filePaths, context), project,
+                                                                             new Convertor<Pair<FilePath, AbstractVcs>, Boolean>() {
+                                                                               public Boolean convert(Pair<FilePath, AbstractVcs> pair) {
+                                                                                 final AbstractVcs vcs = pair.getSecond();
+                                                                                 final FilePath fp = pair.getFirst();
+                                                                                 return vcs.isVersionedDirectory(fp.getVirtualFile());
+                                                                               }
+                                                                             });
         if (roots.length == 0) {
           return;
         }
@@ -369,8 +379,11 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
 
           final SequentialUpdatesContext context = myContextInfo.get(vcs);
           final Ref<SequentialUpdatesContext> refContext = new Ref<SequentialUpdatesContext>(context);
+
+          // actual update
           UpdateSession updateSession =
             updateEnvironment.updateDirectories(files.toArray(new FilePath[files.size()]), myUpdatedFiles, progressIndicator, refContext);
+
           myContextInfo.put(vcs, refContext.get());
           processed++;
           if (progressIndicator != null) {