.filter((p) -> p.first != null) .map((p) -> P4ServerComponent .perform(project, p.first.getClientConfig(), new RevertFileAction(p.second, false)) .whenCompleted((r) -> { LOG.info("Reverted " + p.second);
@Test void curateFile_delete_revert_add() { SimplePendingActionFactory actionFactory = new SimplePendingActionFactory(REF_A1); PendingActionCurator curator = new PendingActionCurator(actionFactory); Map<String, MockVirtualFile> fs = MockVirtualFileSystem.createTree( "a.txt", "abc" ); MockVirtualFile file = fs.get("a.txt"); List<ActionStore.PendingAction> actions = new ArrayList<>(); P4ChangelistIdImpl cl = new P4ChangelistIdImpl(100, REF_A1); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1, new DeleteFileAction(file.asFilePath(), cl)); actions.add(deleteFile); ActionStore.PendingAction revertFile = ActionStore.createPendingAction(REF_A1, new RevertFileAction(file.asFilePath(), false)); actions.add(revertFile); ActionStore.PendingAction addFile = ActionStore.createPendingAction(REF_A1, new AddEditAction(file.asFilePath(), null, cl, (String) null)); curator.curateActionList(addFile, actions); // Because offline revert isn't implemented, the revert then add maintains the integrity. assertContainsExactly(actions, deleteFile, revertFile, addFile); }
@Override public void rollbackIfUnchanged(VirtualFile file) { if (file == null || project.isDisposed()) { return; } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null || registry.isDisposed()) { LOG.info("Skipping revert for " + file + ": plugin not in a valid state"); return; } FilePath fp = VcsUtil.getFilePath(file); if (fp == null) { LOG.info("Skipping revert for " + file + ": no FilePath found"); return; } ClientConfigRoot root = registry.getClientFor(file); if (root == null) { LOG.info("SKipping revert for " + file + ": no P4 root found"); return; } P4ServerComponent .perform(project, root.getClientConfig(), new RevertFileAction(fp, true)) .whenCompleted((r) -> ChangeListManager.getInstance(project).scheduleUpdate(true)); }
state.data.getChangelistIdNullable("cl-id")); case REVERT_FILE: return new RevertFileAction(state.actionId, state.data.getFilePathNotNull("file"), state.data.getBooleanNullable("unchanged", false));
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new RevertFileAction(newFile, false)) .whenCompleted(sink::resolve) .whenServerError(sink::reject)