Search in sources :

Example 21 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgRegularUpdater method processRebase.

private void processRebase(ProgressIndicator indicator, final UpdatedFiles updatedFiles) throws VcsException {
    indicator.setText2(HgVcsMessages.message("hg4idea.progress.rebase"));
    HgRepository repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repoRoot);
    if (repository == null) {
        throw new VcsException("Repository not found for root " + repoRoot);
    }
    HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, repository);
    HgCommandResult result = new HgRebaseCommand(project, repository).startRebase();
    if (HgErrorUtil.isCommandExecutionFailed(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't rebase repository.");
        return;
    }
    //noinspection ConstantConditions
    while (result.getExitValue() == 1) {
        //if result == null isAbort will be true;
        resolvePossibleConflicts(updatedFiles);
        if (HgConflictResolver.hasConflicts(project, repoRoot) || HgErrorUtil.isNothingToRebase(result)) {
            break;
        }
        result = rebaseCommand.continueRebase();
        if (HgErrorUtil.isAbort(result)) {
            new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't continue rebasing");
            break;
        }
    }
    repository.update();
    repoRoot.refresh(true, true);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) VcsException(com.intellij.openapi.vcs.VcsException) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 22 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgRegularUpdater method doMerge.

private HgCommandResult doMerge(ProgressIndicator indicator) throws VcsException {
    indicator.setText2(HgVcsMessages.message("hg4idea.update.progress.merging"));
    HgRepository repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repoRoot);
    if (repository == null) {
        LOG.error("Couldn't find repository for " + repoRoot.getName());
        return null;
    }
    HgMergeCommand mergeCommand = new HgMergeCommand(project, repository);
    //    mergeCommand.setRevision(headToMerge.getRevision());
    return mergeCommand.mergeSynchronously();
}
Also used : HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 23 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository 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)

Example 24 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgIgnoredFileHolder method containsFile.

@Override
public boolean containsFile(VirtualFile file) {
    HgRepository repositoryForFile = HgUtil.getRepositoryForFile(myProject, file);
    if (repositoryForFile == null)
        return false;
    HgLocalIgnoredHolder localIgnoredHolder = myVcsIgnoredHolderMap.get(repositoryForFile);
    return localIgnoredHolder != null && localIgnoredHolder.contains(file);
}
Also used : HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 25 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgCommonDialogWithChoices method updateRepository.

private void updateRepository() {
    HgRepository repo = hgRepositorySelectorComponent.getRepository();
    branchSelector.setModel(new DefaultComboBoxModel(repo.getOpenedBranches().toArray()));
    DefaultComboBoxModel tagComboBoxModel = new DefaultComboBoxModel(HgUtil.getSortedNamesWithoutHashes(repo.getTags()).toArray());
    tagComboBoxModel.addElement(//HgRepository does not store 'tip' tag because it is internal and not included in tags file
    TIP_REFERENCE);
    tagSelector.setModel(tagComboBoxModel);
    bookmarkSelector.setModel(new DefaultComboBoxModel(HgUtil.getSortedNamesWithoutHashes(repo.getBookmarks()).toArray()));
    update();
}
Also used : HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Aggregations

HgRepository (org.zmlx.hg4idea.repo.HgRepository)36 NotNull (org.jetbrains.annotations.NotNull)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Project (com.intellij.openapi.project.Project)7 VcsException (com.intellij.openapi.vcs.VcsException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 File (java.io.File)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)3 Task (com.intellij.openapi.progress.Task)2 AbstractVcsVirtualFile (com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile)2 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)2 HgNameWithHashInfo (org.zmlx.hg4idea.HgNameWithHashInfo)2 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)2