diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index 8e5615c056df..5b56c0fc7a03 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -491,7 +491,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec } } - List getUnversionedFiles() { + public List getUnversionedFiles() { return myComposite.getVFHolder(FileHolder.HolderType.UNVERSIONED).getFiles(); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java index cd54d7e5884f..faef9fb2729d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java @@ -16,10 +16,8 @@ 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 filesToDelete = new ArrayList(myDeletedWithoutConfirmFiles); + final List deletedFiles = new ArrayList(myDeletedFiles); + myDeletedWithoutConfirmFiles.clear(); + myDeletedFiles.clear(); + + // skip unversioned files + final List unversionedFilePaths = new ArrayList(); + for (VirtualFile vf : ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles()) { + unversionedFilePaths.add(VcsUtil.getFilePath(vf.getPath())); + } + for (Iterator iter = filesToDelete.iterator(); iter.hasNext(); ) { + if (unversionedFilePaths.contains(iter.next())) { + iter.remove(); + } + } + for (Iterator 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 filePaths = selectFilePathsToDelete(deletedFiles); + if (filePaths != null) { + filesToDelete.addAll(filePaths); + } + } + } + + performDeletion(filesToDelete); + } + @Override protected void performDeletion(List filesToDelete) { (new VcsBackgroundTask(myProject,