mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Refactor: IDEA-100655 confirmation for removing non-version files bug.
*Move checking if deleted file is unversioned file in needToConfirmDelection override method. *Change skipUnversionedAndNotUnderHg method to just skipNotUnderHg.
This commit is contained in:
@@ -27,8 +27,6 @@ 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;
|
||||
@@ -191,22 +189,22 @@ public class HgVFSListener extends VcsVFSListener {
|
||||
return HgVcsMessages.message("hg4idea.remove.single.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VcsDeleteType needConfirmDeletion(final VirtualFile file) {
|
||||
return ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles().contains(file)
|
||||
? VcsDeleteType.SILENT
|
||||
: VcsDeleteType.CONFIRM;
|
||||
}
|
||||
|
||||
protected void executeDelete() {
|
||||
final List<FilePath> filesToDelete = new ArrayList<FilePath>(myDeletedWithoutConfirmFiles);
|
||||
final List<FilePath> filesToConfirmDeletion = new ArrayList<FilePath>(myDeletedFiles);
|
||||
myDeletedWithoutConfirmFiles.clear();
|
||||
myDeletedFiles.clear();
|
||||
|
||||
// skip unversioned files and files which are not under Mercurial
|
||||
final List<FilePath> unversionedFiles =
|
||||
ContainerUtil.map(ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles(), new Function<VirtualFile, FilePath>() {
|
||||
@Override
|
||||
public FilePath fun(VirtualFile virtualFile) {
|
||||
return new FilePathImpl(virtualFile);
|
||||
}
|
||||
});
|
||||
skipUnversionedAndNotUnderHg(unversionedFiles, filesToDelete);
|
||||
skipUnversionedAndNotUnderHg(unversionedFiles, filesToConfirmDeletion);
|
||||
// skip files which are not under Mercurial
|
||||
skipNotUnderHg(filesToDelete);
|
||||
skipNotUnderHg(filesToConfirmDeletion);
|
||||
|
||||
// newly added files (which were added to the repo but never committed) should be removed from the VCS,
|
||||
// but without user confirmation.
|
||||
@@ -253,17 +251,16 @@ public class HgVFSListener extends VcsVFSListener {
|
||||
* 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<FilePath> unversionedFiles, Collection<FilePath> filesToFilter) {
|
||||
for (Iterator<FilePath> iter = filesToFilter.iterator(); iter.hasNext(); ) {
|
||||
final FilePath filePath = iter.next();
|
||||
if (HgUtil.getHgRootOrNull(myProject, filePath) == null || unversionedFiles.contains(filePath)) {
|
||||
iter.remove();
|
||||
}
|
||||
private void skipNotUnderHg(Collection<FilePath> filesToFilter) {
|
||||
for (Iterator<FilePath> iter = filesToFilter.iterator(); iter.hasNext(); ) {
|
||||
final FilePath filePath = iter.next();
|
||||
if (HgUtil.getHgRootOrNull(myProject, filePath) == null) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performDeletion( final List<FilePath> filesToDelete) {
|
||||
|
||||
Reference in New Issue
Block a user