From b99a028cd32af82da9dd1123a13dc235d17ea298 Mon Sep 17 00:00:00 2001 From: "Nadya.Zabrodina" Date: Tue, 12 Feb 2013 11:51:43 +0400 Subject: [PATCH] IDEA-100655 Mercurial plugin (hg4idea) shouldn't ask confirmation for removing non-version files. *Change skipUnversionedAndNotUnderHg method argument to List unversionedFiles, because all VirtualFiles in filesToFilter are null. So we cannot use contains method of ChangeListManager.getUnversioned, it always return false. (see FilePathImpl constructor if forDeleted var set to true). --- .../src/org/zmlx/hg4idea/HgVFSListener.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java index 46ad9f88d270..cea8a470b92c 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java @@ -27,6 +27,8 @@ import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.AppUIUtil; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.VcsBackgroundTask; import com.intellij.vcsUtil.VcsUtil; @@ -196,9 +198,15 @@ public class HgVFSListener extends VcsVFSListener { myDeletedFiles.clear(); // skip unversioned files and files which are not under Mercurial - final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(myProject); - skipUnversionedAndNotUnderHg(changeListManager, filesToDelete); - skipUnversionedAndNotUnderHg(changeListManager, filesToConfirmDeletion); + final List unversionedFiles = + ContainerUtil.map(ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles(), new Function() { + @Override + public FilePath fun(VirtualFile virtualFile) { + return new FilePathImpl(virtualFile); + } + }); + skipUnversionedAndNotUnderHg(unversionedFiles, filesToDelete); + skipUnversionedAndNotUnderHg(unversionedFiles, filesToConfirmDeletion); // newly added files (which were added to the repo but never committed) should be removed from the VCS, // but without user confirmation. @@ -241,20 +249,21 @@ public class HgVFSListener extends VcsVFSListener { }.queue(); } - /** - * Changes the given collection of files by filtering out unversioned files and - * files which are not under Mercurial repository. - * @param changeListManager instance of the ChangeListManagerImpl to retrieve unversioned files from it. - * @param filesToFilter files to be filtered. - */ - private void skipUnversionedAndNotUnderHg(ChangeListManagerImpl changeListManager, Collection filesToFilter) { - for (Iterator iter = filesToFilter.iterator(); iter.hasNext(); ) { - final FilePath filePath = iter.next(); - if (HgUtil.getHgRootOrNull(myProject, filePath) == null || changeListManager.isUnversioned(filePath.getVirtualFile())) { - iter.remove(); + /** + * Changes the given collection of files by filtering out unversioned files and + * files which are not under Mercurial repository. + * + * @param unversionedFiles list of unversioned files + * @param filesToFilter files to be filtered. + */ + private void skipUnversionedAndNotUnderHg(List unversionedFiles, Collection filesToFilter) { + for (Iterator iter = filesToFilter.iterator(); iter.hasNext(); ) { + final FilePath filePath = iter.next(); + if (HgUtil.getHgRootOrNull(myProject, filePath) == null || unversionedFiles.contains(filePath)) { + iter.remove(); + } } } - } @Override protected void performDeletion( final List filesToDelete) {