Search in sources :

Example 1 with UpdatedFiles

use of com.intellij.openapi.vcs.update.UpdatedFiles in project intellij-community by JetBrains.

the class HgCherryPicker method processGrafting.

private static void processGrafting(@NotNull HgRepository repository, @NotNull List<String> hashes) {
    Project project = repository.getProject();
    VirtualFile root = repository.getRoot();
    HgGraftCommand command = new HgGraftCommand(project, repository);
    HgCommandResult result = command.startGrafting(hashes);
    boolean hasConflicts = HgConflictResolver.hasConflicts(project, root);
    if (!hasConflicts && HgErrorUtil.isCommandExecutionFailed(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't  graft.");
        return;
    }
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    while (hasConflicts) {
        new HgConflictResolver(project, updatedFiles).resolve(root);
        hasConflicts = HgConflictResolver.hasConflicts(project, root);
        if (!hasConflicts) {
            result = command.continueGrafting();
            hasConflicts = HgConflictResolver.hasConflicts(project, root);
        } else {
            new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't continue grafting");
            break;
        }
    }
    repository.update();
    root.refresh(true, true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgGraftCommand(org.zmlx.hg4idea.command.HgGraftCommand) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) HgConflictResolver(org.zmlx.hg4idea.provider.update.HgConflictResolver)

Example 2 with UpdatedFiles

use of com.intellij.openapi.vcs.update.UpdatedFiles in project intellij-community by JetBrains.

the class HgTaskHandler method mergeAndClose.

@Override
protected void mergeAndClose(@NotNull final String branch, @NotNull final List<HgRepository> repositories) {
    String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
    FileDocumentManager.getInstance().saveAllDocuments();
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    for (final HgRepository repository : repositories) {
        HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, new Runnable() {

            @Override
            public void run() {
                Project project = repository.getProject();
                VirtualFile repositoryRoot = repository.getRoot();
                try {
                    new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
                    HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
                } catch (HgCommandException e) {
                    HgErrorUtil.handleException(project, e);
                } catch (VcsException e) {
                    VcsNotifier.getInstance(project).notifyError("Exception during merge commit with " + branch, e.getMessage());
                }
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) VcsException(com.intellij.openapi.vcs.VcsException) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgCommandException(org.zmlx.hg4idea.execution.HgCommandException)

Example 3 with UpdatedFiles

use of com.intellij.openapi.vcs.update.UpdatedFiles in project intellij-community by JetBrains.

the class SvnNativeClientAuthTest method updateExpectAuthCanceled.

private void updateExpectAuthCanceled(File wc1, String expectedText) {
    Assert.assertTrue(wc1.isDirectory());
    final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(wc1);
    final UpdatedFiles files = UpdatedFiles.create();
    final UpdateSession session = myVcs.getUpdateEnvironment().updateDirectories(new FilePath[] { VcsUtil.getFilePath(vf) }, files, new EmptyProgressIndicator(), new Ref<>());
    Assert.assertTrue(session.getExceptions() != null && !session.getExceptions().isEmpty());
    Assert.assertTrue(!session.isCanceled());
    Assert.assertTrue(session.getExceptions().get(0).getMessage().contains(expectedText));
    if (myIsSecure) {
        ++myExpectedCreds;
        ++myExpectedCert;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) UpdateSession(com.intellij.openapi.vcs.update.UpdateSession) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles)

Example 4 with UpdatedFiles

use of com.intellij.openapi.vcs.update.UpdatedFiles in project intellij-community by JetBrains.

the class GitPushOperation method prepareCombinedResult.

private GitPushResult prepareCombinedResult(final Map<GitRepository, GitPushRepoResult> allRoots, final Map<GitRepository, GitUpdateResult> updatedRoots, final Map<GitRepository, String> preUpdatePositions, Label beforeUpdateLabel, Label afterUpdateLabel) {
    Map<GitRepository, GitPushRepoResult> results = ContainerUtil.newHashMap();
    UpdatedFiles updatedFiles = UpdatedFiles.create();
    for (Map.Entry<GitRepository, GitPushRepoResult> entry : allRoots.entrySet()) {
        GitRepository repository = entry.getKey();
        GitPushRepoResult simpleResult = entry.getValue();
        GitUpdateResult updateResult = updatedRoots.get(repository);
        if (updateResult == null) {
            results.put(repository, simpleResult);
        } else {
            collectUpdatedFiles(updatedFiles, repository, preUpdatePositions.get(repository));
            results.put(repository, GitPushRepoResult.addUpdateResult(simpleResult, updateResult));
        }
    }
    return new GitPushResult(results, updatedFiles, beforeUpdateLabel, afterUpdateLabel);
}
Also used : GitRepository(git4idea.repo.GitRepository) GitUpdateResult(git4idea.update.GitUpdateResult) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles)

Example 5 with UpdatedFiles

use of com.intellij.openapi.vcs.update.UpdatedFiles in project intellij-community by JetBrains.

the class GitPushResultNotification method create.

@NotNull
static GitPushResultNotification create(@NotNull Project project, @NotNull GitPushResult pushResult, boolean multiRepoProject) {
    GroupedPushResult grouped = GroupedPushResult.group(pushResult.getResults());
    String title;
    NotificationType type;
    if (!grouped.errors.isEmpty()) {
        if (!grouped.successful.isEmpty()) {
            title = "Push partially failed";
        } else {
            title = "Push failed";
        }
        type = NotificationType.ERROR;
    } else if (!grouped.rejected.isEmpty() || !grouped.customRejected.isEmpty()) {
        if (!grouped.successful.isEmpty()) {
            title = "Push partially rejected";
        } else {
            title = "Push rejected";
        }
        type = NotificationType.WARNING;
    } else {
        title = "Push successful";
        type = NotificationType.INFORMATION;
    }
    String description = formDescription(pushResult.getResults(), multiRepoProject);
    ViewUpdatedFilesNotificationListener listener = null;
    UpdatedFiles updatedFiles = pushResult.getUpdatedFiles();
    if (!updatedFiles.isEmpty()) {
        description += "<br/>" + VIEW_FILES_UPDATED_DURING_THE_PUSH;
        listener = new ViewUpdatedFilesNotificationListener(project, updatedFiles, pushResult.getBeforeUpdateLabel(), pushResult.getAfterUpdateLabel());
    }
    NotificationGroup group = type == NotificationType.INFORMATION ? VcsNotifier.NOTIFICATION_GROUP_ID : VcsNotifier.IMPORTANT_ERROR_NOTIFICATION;
    return new GitPushResultNotification(group.getDisplayId(), title, description, type, listener);
}
Also used : NotificationType(com.intellij.notification.NotificationType) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles) NotificationGroup(com.intellij.notification.NotificationGroup) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

UpdatedFiles (com.intellij.openapi.vcs.update.UpdatedFiles)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)4 UpdateSession (com.intellij.openapi.vcs.update.UpdateSession)3 Project (com.intellij.openapi.project.Project)2 VcsException (com.intellij.openapi.vcs.VcsException)2 NotificationGroup (com.intellij.notification.NotificationGroup)1 NotificationType (com.intellij.notification.NotificationType)1 ProjectLevelVcsManagerEx (com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx)1 UpdateInfoTree (com.intellij.openapi.vcs.update.UpdateInfoTree)1 GitVcs (git4idea.GitVcs)1 GitRepository (git4idea.repo.GitRepository)1 GitUpdateResult (git4idea.update.GitUpdateResult)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)1 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)1 HgGraftCommand (org.zmlx.hg4idea.command.HgGraftCommand)1 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)1 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)1