Search in sources :

Example 1 with HgResolveStatusEnum

use of org.zmlx.hg4idea.command.HgResolveStatusEnum 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 HgResolveStatusEnum

use of org.zmlx.hg4idea.command.HgResolveStatusEnum 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 3 with HgResolveStatusEnum

use of org.zmlx.hg4idea.command.HgResolveStatusEnum 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)3 HgResolveCommand (org.zmlx.hg4idea.command.HgResolveCommand)3 HgResolveStatusEnum (org.zmlx.hg4idea.command.HgResolveStatusEnum)3 File (java.io.File)2 HgFile (org.zmlx.hg4idea.HgFile)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 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 List (java.util.List)1 Map (java.util.Map)1