Search in sources :

Example 1 with HgResolveCommand

use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.

the class HgRunConflictResolverDialog method onChangeRepository.

private void onChangeRepository() {
    VirtualFile repo = repositorySelector.getRepository().getRoot();
    HgResolveCommand command = new HgResolveCommand(project);
    final ModalityState modalityState = ApplicationManager.getApplication().getModalityStateForComponent(getRootPane());
    command.getListAsynchronously(repo, new Consumer<Map<HgFile, HgResolveStatusEnum>>() {

        @Override
        public void consume(Map<HgFile, HgResolveStatusEnum> status) {
            final DefaultListModel model = new DefaultListModel();
            for (Map.Entry<HgFile, HgResolveStatusEnum> entry : status.entrySet()) {
                if (entry.getValue() == HgResolveStatusEnum.UNRESOLVED) {
                    model.addElement(entry.getKey().getRelativePath());
                }
            }
            ApplicationManager.getApplication().invokeLater(new Runnable() {

                @Override
                public void run() {
                    setOKActionEnabled(!model.isEmpty());
                    if (model.isEmpty()) {
                        model.addElement("No conflicts to resolve");
                    }
                    conflictsList.setModel(model);
                }
            }, modalityState);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) HgResolveStatusEnum(org.zmlx.hg4idea.command.HgResolveStatusEnum) ModalityState(com.intellij.openapi.application.ModalityState) Map(java.util.Map)

Example 2 with HgResolveCommand

use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.

the class HgMarkResolved method batchPerform.

protected void batchPerform(Project project, HgVcs activeVcs, List<VirtualFile> files, DataContext context) throws VcsException {
    HgResolveCommand resolveCommand = new HgResolveCommand(project);
    for (VirtualFile file : files) {
        VirtualFile root = VcsUtil.getVcsRootFor(project, file);
        if (root == null) {
            return;
        }
        resolveCommand.markResolved(root, file);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand)

Example 3 with HgResolveCommand

use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.

the class HgRollbackEnvironment method revert.

private void revert(@NotNull List<FilePath> filePaths) {
    for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(project, filePaths).entrySet()) {
        final VirtualFile repo = entry.getKey();
        final Collection<FilePath> files = entry.getValue();
        HgRevisionNumber revisionNumber = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
        for (List<String> chunk : VcsFileUtil.chunkPaths(repo, files)) {
            HgCommandResult revertResult = new HgRevertCommand(project).execute(repo, chunk, revisionNumber, false);
            if (HgErrorUtil.hasUncommittedChangesConflict(revertResult)) {
                String message = String.format("<html>Revert failed due to uncommitted merge.<br>" + "Would you like to discard all changes for repository <it><b>%s</b></it>?</html>", repo.getPresentableName());
                int exitCode = HgUpdateCommand.showDiscardChangesConfirmation(project, message);
                if (exitCode == Messages.OK) {
                    //discard all changes for this repository//
                    HgUpdateCommand updateCommand = new HgUpdateCommand(project, repo);
                    updateCommand.setClean(true);
                    updateCommand.setRevision(".");
                    updateCommand.execute();
                }
                break;
            }
            new HgResolveCommand(project).markResolved(repo, files);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) HgUpdateCommand(org.zmlx.hg4idea.command.HgUpdateCommand) HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber)

Example 4 with HgResolveCommand

use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.

the class HgConflictResolver method resolve.

public void resolve(final VirtualFile repo) {
    final Map<HgFile, HgResolveStatusEnum> resolves = new HgResolveCommand(myProject).getListSynchronously(repo);
    final List<File> conflictFiles = new ArrayList<>();
    for (HgFile hgFile : resolves.keySet()) {
        File file = hgFile.getFile();
        if (resolves.get(hgFile) == HgResolveStatusEnum.UNRESOLVED) {
            conflictFiles.add(file);
            updateUpdatedFiles(file, true);
        } else {
            updateUpdatedFiles(file, false);
        }
    }
    if (conflictFiles.isEmpty())
        return;
    final HgVcs vcs = HgVcs.getInstance(myProject);
    if (vcs == null)
        return;
    final List<VirtualFile> conflicts = sortVirtualFilesByPresentation(findVirtualFilesWithRefresh(conflictFiles));
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {

        public void run() {
            AbstractVcsHelper.getInstance(myProject).showMergeDialog(conflicts, vcs.getMergeProvider());
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgVcs(org.zmlx.hg4idea.HgVcs) HgFile(org.zmlx.hg4idea.HgFile) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) HgResolveStatusEnum(org.zmlx.hg4idea.command.HgResolveStatusEnum) ArrayList(java.util.ArrayList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile)

Example 5 with HgResolveCommand

use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.

the class HgChangeProvider method process.

private Collection<HgChange> process(ChangelistBuilder builder, Collection<FilePath> files) {
    final Set<HgChange> hgChanges = new HashSet<>();
    for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(myProject, files).entrySet()) {
        VirtualFile repo = entry.getKey();
        final HgRevisionNumber workingRevision = new HgWorkingCopyRevisionsCommand(myProject).identify(repo).getFirst();
        final HgRevisionNumber parentRevision = new HgWorkingCopyRevisionsCommand(myProject).firstParent(repo);
        final Map<HgFile, HgResolveStatusEnum> list = new HgResolveCommand(myProject).getListSynchronously(repo);
        hgChanges.addAll(new HgStatusCommand.Builder(true).ignored(false).build(myProject).executeInCurrentThread(repo, entry.getValue()));
        final HgRepository hgRepo = HgUtil.getRepositoryForFile(myProject, repo);
        if (hgRepo != null && hgRepo.hasSubrepos()) {
            hgChanges.addAll(ContainerUtil.mapNotNull(hgRepo.getSubrepos(), info -> findChange(hgRepo, info)));
        }
        sendChanges(builder, hgChanges, list, workingRevision, parentRevision);
    }
    return hgChanges;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsUtil(com.intellij.vcsUtil.VcsUtil) HgStatusCommand(org.zmlx.hg4idea.command.HgStatusCommand) java.util(java.util) org.zmlx.hg4idea(org.zmlx.hg4idea) HgResolveStatusEnum(org.zmlx.hg4idea.command.HgResolveStatusEnum) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand) VirtualFile(com.intellij.openapi.vfs.VirtualFile) com.intellij.openapi.vcs.changes(com.intellij.openapi.vcs.changes) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) ContainerUtil(com.intellij.util.containers.ContainerUtil) File(java.io.File) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) Project(com.intellij.openapi.project.Project) VfsUtil(com.intellij.openapi.vfs.VfsUtil) com.intellij.openapi.vcs(com.intellij.openapi.vcs) NotNull(org.jetbrains.annotations.NotNull) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgUtil(org.zmlx.hg4idea.util.HgUtil) JBColor(com.intellij.ui.JBColor) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) HgResolveStatusEnum(org.zmlx.hg4idea.command.HgResolveStatusEnum) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand) HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 HgResolveCommand (org.zmlx.hg4idea.command.HgResolveCommand)5 HgResolveStatusEnum (org.zmlx.hg4idea.command.HgResolveStatusEnum)3 File (java.io.File)2 HgFile (org.zmlx.hg4idea.HgFile)2 HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)2 ModalityState (com.intellij.openapi.application.ModalityState)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 com.intellij.openapi.vcs (com.intellij.openapi.vcs)1 FilePath (com.intellij.openapi.vcs.FilePath)1 com.intellij.openapi.vcs.changes (com.intellij.openapi.vcs.changes)1 VfsUtil (com.intellij.openapi.vfs.VfsUtil)1 JBColor (com.intellij.ui.JBColor)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 VcsUtil (com.intellij.vcsUtil.VcsUtil)1 java.awt (java.awt)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1