/** * Force a sync from server operation to overwrite local changes. * @param files files to sync * @param exceptions exceptions encountered * @param listener listener on progress */ private void forceSync(List<FilePath> files, List<VcsException> exceptions, RollbackProgressListener listener) { if (files.isEmpty() || project.isDisposed()) { return; } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null || registry.isDisposed()) { return; } groupFilesByClient(registry, files) .stream() .map(e -> P4ServerComponent .perform(project, e.getKey().getClientConfig(), new FetchFilesAction(e.getValue(), "", true)) .whenCompleted((c) -> listener.accept(e.getValue())) .whenServerError((ex) -> listener.accept(e.getValue())) .whenOffline(() -> listener.accept(e.getValue()))) .collect(ErrorCollectors.collectActionErrors(exceptions)) .whenCompleted((c) -> LOG.info("Completed sync of files")) .whenFailed((c) -> LOG.info("Failed to sync files")); }
P4ServerComponent .perform(project, key.getClientConfig(), new FetchFilesAction(value, options.getSpecAnnotation(), options.isForce())) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project),
@Test void fetchFiles() { PendingActionCurator.PendingActionFactory actionFactory = mock(PendingActionCurator.PendingActionFactory.class); PendingActionCurator curator = new PendingActionCurator(actionFactory); FetchFilesAction addedAction = new FetchFilesAction(Collections.emptyList(), null, false); CreateChangelistAction existingAction = new CreateChangelistAction(REF_B2, "comment", "local-id"); ActionStore.PendingAction added = ActionStore.createPendingAction(REF_B2, addedAction); ActionStore.PendingAction existing = ActionStore.createPendingAction(REF_B2, existingAction); PendingActionCurator.CurateResult res = curator.curate(added, existing); assertEquals(PendingActionCurator.KEEP_EXISTING_REMOVE_ADDED_STOP, res); }
@Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); progressIndicator.startNonCancelableSection(); try { LOG.info("Fetching files into " + rootPath); FetchFilesResult r = P4ServerComponent .perform(project, clientConfig, new FetchFilesAction(Collections.singletonList(rootPath), null, false)) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project), TimeUnit.MILLISECONDS); progressIndicator.finishNonCancelableSection(); synchronized (sync) { res = r; } } catch (InterruptedException e) { InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>( new VcsInterruptedException(e))); progressIndicator.finishNonCancelableSection(); onCancel(); } catch (P4CommandRunner.ServerResultException e) { progressIndicator.finishNonCancelableSection(); VcsNotifier.getInstance(project).notifyError(P4Bundle.getString("checkout.config.error.title"), e.getMessage()); synchronized (sync) { res = null; } } progressIndicator.stop(); }
.futureMap((runner, sink) -> runner.perform(clientConfig, new FetchFilesAction(Collections.singletonList(VcsUtil.getFilePath(clientRoot)), null, false)) .whenCompleted(sink::resolve)
clientConfig, new FetchFilesAction(Collections.singletonList(newFile), "@" + committedChangelistId[0], false))) .mapQueryAsync((res) -> runner.listFilesDetails(
clientConfig, new FetchFilesAction(Collections.singletonList(newFile), "@" + committedChangelistId[0], false)))