void (@NotNull List<MovedFileInfo> movedFiles) { final List<MovedFileInfo> failedToMove = new ArrayList<>(); (new VcsBackgroundTask<>(myProject, HgBundle.message("hg4idea.move.progress"), movedFiles) { @Override public void onFinished() { if (!failedToMove.isEmpty()) { handleRenameError(); } } private void handleRenameError() { NotificationAction viewFilesAction = NotificationAction.createSimple(VcsBundle.messagePointer("action.NotificationAction.VFSListener.text.view.files"), () -> { List<FilePath> filePaths = ContainerUtil.map(failedToMove, movedInfo -> movedInfo.getOldPath()); DialogWrapper dialog = new ProcessedFilePathsDialog(myProject, filePaths); dialog.setTitle(HgBundle.message("hg4idea.rename.error.title")); dialog.show(); }); NotificationAction retryAction = NotificationAction.createSimpleExpiring(HgBundle.message("retry"), () -> performMoveRename(failedToMove)); VcsNotifier.getInstance(myProject) .notifyError(RENAME_FAILED, HgBundle.message("hg4idea.rename.error"), HgBundle.message("hg4idea.rename.error.msg"), viewFilesAction, retryAction); } @Override protected void process(final MovedFileInfo file) { final FilePath source = file.getOldPath(); final FilePath target = file.getNewPath(); VirtualFile sourceRoot = VcsUtil.getVcsRootFor(myProject, source); VirtualFile targetRoot = VcsUtil.getVcsRootFor(myProject, target); if (sourceRoot != null && sourceRoot.equals(targetRoot)) { HgCommandResult result; int attempt = 0; do { result = new HgMoveCommand(myProject).execute(sourceRoot, source, target); } while (HgErrorUtil.isWLockError(result) && attempt++ < 2); if (!HgErrorUtil.hasErrorsInCommandExecution(result)) { dirtyScopeManager.fileDirty(source); dirtyScopeManager.fileDirty(target); } else { failedToMove.add(file); LOG.warn("Hg rename failed:" + result.getRawError()); } } } }).queue(); }