[Mercurial] IDEA-55949 don't ask confirmation for removing unversioned files
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 24 Jun 2010 12:13:38 +0000 (16:13 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 24 Jun 2010 12:13:38 +0000 (16:13 +0400)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java

index 8e5615c056df21676802aabb4805801331cb356e..5b56c0fc7a03657b309cbab173962c6a478bb795 100644 (file)
@@ -491,7 +491,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
     }
   }
 
-  List<VirtualFile> getUnversionedFiles() {
+  public List<VirtualFile> getUnversionedFiles() {
     return myComposite.getVFHolder(FileHolder.HolderType.UNVERSIONED).getFiles();
   }
 
index cd54d7e5884f0906b3defbdb3afc9216ed4a2019..faef9fb2729d9bcdca8ab5720aa8d7f2111f1eee 100644 (file)
 package org.zmlx.hg4idea;
 
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.FilePath;
-import com.intellij.openapi.vcs.VcsConfiguration;
-import com.intellij.openapi.vcs.VcsException;
-import com.intellij.openapi.vcs.VcsVFSListener;
+import com.intellij.openapi.vcs.*;
+import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
 import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.ui.VcsBackgroundTask;
@@ -29,9 +27,7 @@ import org.zmlx.hg4idea.command.HgCopyCommand;
 import org.zmlx.hg4idea.command.HgMoveCommand;
 import org.zmlx.hg4idea.command.HgRemoveCommand;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Listens to VFS events (such as adding or deleting bunch of files) and performs necessary operations with the VCS.
@@ -98,6 +94,44 @@ public class HgVFSListener extends VcsVFSListener {
     return HgVcsMessages.message("hg4idea.remove.single.body");
   }
 
+  protected void executeDelete() {
+    final List<FilePath> filesToDelete = new ArrayList<FilePath>(myDeletedWithoutConfirmFiles);
+    final List<FilePath> deletedFiles = new ArrayList<FilePath>(myDeletedFiles);
+    myDeletedWithoutConfirmFiles.clear();
+    myDeletedFiles.clear();
+
+    // skip unversioned files
+    final List<FilePath> unversionedFilePaths = new ArrayList<FilePath>();
+    for (VirtualFile vf : ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles()) {
+      unversionedFilePaths.add(VcsUtil.getFilePath(vf.getPath()));
+    }
+    for (Iterator<FilePath> iter = filesToDelete.iterator(); iter.hasNext(); ) {
+      if (unversionedFilePaths.contains(iter.next())) {
+        iter.remove();
+      }
+    }
+    for (Iterator<FilePath> iter = deletedFiles.iterator(); iter.hasNext(); ) {
+      if (unversionedFilePaths.contains(iter.next())) {
+        iter.remove();
+      }
+    }
+
+    // confirm removal from the VCS if needed
+    if (myRemoveOption.getValue() != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
+      if (myRemoveOption.getValue() == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY || deletedFiles.isEmpty()) {
+        filesToDelete.addAll(deletedFiles);
+      }
+      else {
+        Collection<FilePath> filePaths = selectFilePathsToDelete(deletedFiles);
+        if (filePaths != null) {
+          filesToDelete.addAll(filePaths);
+        }
+      }
+    }
+    
+    performDeletion(filesToDelete);
+  }
+
   @Override
   protected void performDeletion(List<FilePath> filesToDelete) {
     (new VcsBackgroundTask<FilePath>(myProject,