Search in sources :

Example 6 with HgWorkingCopyRevisionsCommand

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

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

the class HgDiffProvider method getLastRevision.

public ItemLatestState getLastRevision(FilePath filePath) {
    VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath);
    if (vcsRoot == null) {
        return null;
    }
    HgWorkingCopyRevisionsCommand command = new HgWorkingCopyRevisionsCommand(project);
    HgRevisionNumber currentRevision = command.identify(vcsRoot).getFirst();
    if (currentRevision == null) {
        return null;
    }
    boolean fileExists = filePath.getIOFile().exists();
    if (currentRevision.isWorkingVersion()) {
        return new ItemLatestState(command.firstParent(vcsRoot), fileExists, true);
    }
    return new ItemLatestState(currentRevision, fileExists, true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) ItemLatestState(com.intellij.openapi.vcs.diff.ItemLatestState) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)

Example 8 with HgWorkingCopyRevisionsCommand

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

the class HgDiffProvider method getCurrentRevision.

public VcsRevisionNumber getCurrentRevision(VirtualFile file) {
    VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, file);
    if (vcsRoot == null) {
        return null;
    }
    FilePath filePath = ObjectsConvertor.VIRTUAL_FILEPATH.convert(file);
    return new HgWorkingCopyRevisionsCommand(project).parents(vcsRoot, filePath).first;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)

Aggregations

HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 NotNull (org.jetbrains.annotations.NotNull)4 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)4 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 FilePath (com.intellij.openapi.vcs.FilePath)2 File (java.io.File)2 HgFile (org.zmlx.hg4idea.HgFile)2 HgResolveCommand (org.zmlx.hg4idea.command.HgResolveCommand)2 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 com.intellij.openapi.vcs (com.intellij.openapi.vcs)1 VcsException (com.intellij.openapi.vcs.VcsException)1 com.intellij.openapi.vcs.changes (com.intellij.openapi.vcs.changes)1 ItemLatestState (com.intellij.openapi.vcs.diff.ItemLatestState)1 MergeData (com.intellij.openapi.vcs.merge.MergeData)1 VfsUtil (com.intellij.openapi.vfs.VfsUtil)1 JBColor (com.intellij.ui.JBColor)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1