FilePath path = VcsUtil.getFilePath(file); return P4ServerComponent .perform(project, entity.first, new AddEditAction(path, null, p4cl, path.getCharset(project))) .whenCompleted((r) -> VcsDirtyScopeManager.getInstance(project).filesDirty(Collections.singleton(file), null)) .whenServerError((err) -> exceptions.add(new VcsException(err)))
@Test void curateFile_add_delete() { Map<String, MockVirtualFile> fs = MockVirtualFileSystem.createTree( "a.txt", "abc" ); MockVirtualFile f1 = fs.get("a.txt"); PendingActionCurator.PendingActionFactory actionFactory = mock(PendingActionCurator.PendingActionFactory.class); PendingActionCurator curator = new PendingActionCurator(actionFactory); List<ActionStore.PendingAction> actions = new ArrayList<>(); P4ChangelistIdImpl cl = new P4ChangelistIdImpl(100, REF_A1); ActionStore.PendingAction addFile = ActionStore.createPendingAction(REF_A1, new AddEditAction( f1.asFilePath(), null, cl, (String) null)); actions.add(addFile); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1, new DeleteFileAction(f1.asFilePath(), cl)); curator.curateActionList(deleteFile, actions); // Delete file cannot tell if the file was open for add or edit, so it must be left alone. assertContainsExactly(actions, addFile, deleteFile); }
new AddEditAction(fp, getFileType(fp), id, (String) null)) .whenAnyState(() -> { if (LOG.isDebugEnabled()) {
@Test void curateFile_delete_add_delete() { 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 addFile = ActionStore.createPendingAction(REF_A1, new AddEditAction(file.asFilePath(), null, cl, (String) null)); actions.add(addFile); // Reuse the delete request curator.curateActionList(deleteFile, actions); // Because we stop looking with the delete -> add, the list should be maintained as expected. assertContainsExactly(actions, deleteFile, addFile, deleteFile); }
.perform(project, root.getClientConfig(), new AddEditAction(fp, getFileType(fp), id, (String) null)) .whenCompleted((res) -> ChangeListManager.getInstance(project).scheduleUpdate(true))
@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); }
@Test void curateFile_addTgt_moveSrc_deleteSrc() { SimplePendingActionFactory actionFactory = new SimplePendingActionFactory(REF_A1); PendingActionCurator curator = new PendingActionCurator(actionFactory); Map<String, MockVirtualFile> fs = MockVirtualFileSystem.createTree( "a.txt", "abc", "b.txt", "def" ); MockVirtualFile src = fs.get("a.txt"); MockVirtualFile tgt = fs.get("b.txt"); List<ActionStore.PendingAction> actions = new ArrayList<>(); P4ChangelistIdImpl cl1 = new P4ChangelistIdImpl(100, REF_A1); P4ChangelistIdImpl cl2 = new P4ChangelistIdImpl(100, REF_A1); ActionStore.PendingAction addFile = ActionStore.createPendingAction(REF_A1, new AddEditAction(tgt.asFilePath(), null, cl1, (String) null)); actions.add(addFile); ActionStore.PendingAction moveFile = ActionStore.createPendingAction(REF_A1, new MoveFileAction(src.asFilePath(), tgt.asFilePath(), cl1)); actions.add(moveFile); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1, new DeleteFileAction(src.asFilePath(), cl2)); curator.curateActionList(deleteFile, actions); assertSize(0, actionFactory.created); assertContainsExactly(actions, addFile, moveFile); }
new AddEditAction(tgt.asFilePath(), null, cl1, (String) null)); actions.add(addFile); ActionStore.PendingAction moveFile = ActionStore.createPendingAction(REF_A1,
.perform(root.getClientConfig(), new AddEditAction(addedFile, null, defaultChangeId, (String) null)); assertSize(0, errors); assertSize(1, vcs.cacheComponent.getState().pendingActions);
.perform(root.getClientConfig(), new AddEditAction(addedFile, null, newP4Change, "UTF-8")); assertSize(0, errors); assertSize(1, vcs.cacheComponent.getState().pendingActions);
new AddEditAction(fp, getFileType(fp), id, (String) null)) .whenCompleted((res) -> { LOG.info("Opened for add/edit: " + fp + ": add? " + res.isAdd() + "; cl: " + res.getChangelistId());
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .whenCompleted(sink::resolve) .whenServerError(sink::reject)
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction(
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .mapActionAsync((res) -> runner.perform(clientConfig, new CreateChangelistAction(clientConfig.getClientServerRef(),
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction( Collections.singletonList(newFile), null, "add file", null))) .mapActionAsync((res) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, (String) null))) .mapQueryAsync((res) -> runner.getFileAnnotation(serverConfig,
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction( Collections.singletonList(newFile), null, "add file", null))) .mapActionAsync((res) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, (String) null))) .whenCompleted(sink::resolve) .whenServerError(sink::reject)
.futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction(
.perform(root.getClientConfig(), new AddEditAction(addedFile, null, defaultChangeId, (String) null)); errors.assertEmpty(); assertSize(1, vcs.cacheComponent.getState().pendingActions);
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .whenCompleted(sink::resolve) .whenServerError(sink::reject)
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new AddEditAction(newFile, null, defaultId, (String) null)) .whenCompleted(sink::resolve) .whenServerError(sink::reject)