Search in sources :

Example 46 with FilePath

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

the class RollbackProgressModifier method accept.

public void accept(final List<FilePath> paths) {
    if (myIndicator != null) {
        if (paths != null && (!paths.isEmpty())) {
            for (FilePath path : paths) {
                checkName(path.getPath());
            }
            myIndicator.setFraction(myCnt / myTotal);
            myIndicator.setText2(VcsBundle.message("rolling.back.file", paths.get(0).getPath()));
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 47 with FilePath

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

the class AnnotateRevisionAction method getFile.

@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
    final Boolean nonLocal = e.getData(VcsDataKeys.VCS_NON_LOCAL_HISTORY_SESSION);
    if (Boolean.TRUE.equals(nonLocal))
        return null;
    VirtualFile file = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
    if (file == null || file.isDirectory())
        return null;
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    if (filePath == null || filePath.getFileType().isBinary())
        return null;
    return file;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) Nullable(org.jetbrains.annotations.Nullable)

Example 48 with FilePath

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

the class GetVersionAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
    if (e.getProject() == null || filePath == null || revision == null) {
        e.getPresentation().setEnabledAndVisible(false);
    } else {
        e.getPresentation().setEnabledAndVisible(isContentAvailable(filePath, revision, e));
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 49 with FilePath

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

the class GetVersionAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    if (ChangeListManager.getInstance(project).isFreezedWithNotification(null))
        return;
    VcsFileRevision revision = e.getRequiredData(VcsDataKeys.VCS_FILE_REVISION);
    FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);
    doGet(project, revision, filePath);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 50 with FilePath

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

the class VcsLogUtil method collectRoots.

@NotNull
private static Set<VirtualFile> collectRoots(@NotNull Collection<FilePath> files, @NotNull Set<VirtualFile> roots) {
    Set<VirtualFile> selectedRoots = new HashSet<>();
    List<VirtualFile> sortedRoots = ContainerUtil.sorted(roots, Comparator.comparing(VirtualFile::getPath));
    for (FilePath filePath : files) {
        VirtualFile virtualFile = filePath.getVirtualFile();
        if (virtualFile != null && roots.contains(virtualFile)) {
            // if a root itself is selected, add this root
            selectedRoots.add(virtualFile);
        } else {
            VirtualFile candidateAncestorRoot = null;
            for (VirtualFile root : sortedRoots) {
                if (FileUtil.isAncestor(VfsUtilCore.virtualToIoFile(root), filePath.getIOFile(), false)) {
                    candidateAncestorRoot = root;
                }
            }
            if (candidateAncestorRoot != null) {
                selectedRoots.add(candidateAncestorRoot);
            }
        }
        // add all roots under selected path
        if (virtualFile != null) {
            for (VirtualFile root : roots) {
                if (VfsUtilCore.isAncestor(virtualFile, root, false)) {
                    selectedRoots.add(root);
                }
            }
        }
    }
    return selectedRoots;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)167 VirtualFile (com.intellij.openapi.vfs.VirtualFile)68 NotNull (org.jetbrains.annotations.NotNull)43 VcsException (com.intellij.openapi.vcs.VcsException)34 File (java.io.File)30 Change (com.intellij.openapi.vcs.changes.Change)26 Nullable (org.jetbrains.annotations.Nullable)22 Project (com.intellij.openapi.project.Project)20 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)15 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)13 FileStatus (com.intellij.openapi.vcs.FileStatus)10 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)8 GitRepository (git4idea.repo.GitRepository)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Test (org.junit.Test)6 StringUtil (com.intellij.openapi.util.text.StringUtil)5 Logger (com.intellij.openapi.diagnostic.Logger)4