/** * 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")); }
private FetchFilesResult fetchFiles(IClient client, ClientConfig config, FetchFilesAction action) throws P4JavaException { List<IFileSpec> files = FileSpecBuildUtil.escapedForFilePathsAnnotated( action.getSyncPaths(), action.getPathAnnotation(), true); List<IFileSpec> res = cmd.syncFiles(client, files, action.isForce()); List<P4LocalFile> resFiles = new ArrayList<>(res.size()); StringBuilder info = new StringBuilder(); for (IFileSpec spec : res) { IServerMessage msg = spec.getStatusMessage(); if (msg != null) { if (msg.isInfo()) { info.append("\n").append(msg.getLocalizedMessage()); } // 17 (x11) = "file(s) up-to-date" if (msg.getGeneric() != MessageGenericCode.EV_EMPTY) { throw new RequestException(msg); } else if (LOG.isDebugEnabled()) { LOG.debug("Ignoring message " + msg); } } else { resFiles.add(new P4LocalFileImpl(config.getClientServerRef(), spec)); } } return new FetchFilesResult(config, resFiles, info.toString()); }
(ClientActionRunner<FetchFilesResult>) (config, action) -> new ActionAnswerImpl<>(connectionManager.withConnection(config, ((FetchFilesAction) action).getCommonDir(), (client) -> fetchFiles(client, config, (FetchFilesAction) action))));
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)))