Search in sources :

Example 41 with FilePath

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

the class SelectFilesToAddTextsToPatchPanel method getBig.

public static Set<Change> getBig(List<Change> changes) {
    final Set<Change> exclude = new HashSet<>();
    for (Change change : changes) {
        // try to estimate size via VF: we assume that base content hasn't been changed much
        VirtualFile virtualFile = getVfFromChange(change);
        if (virtualFile != null) {
            if (isBig(virtualFile)) {
                exclude.add(change);
            }
            continue;
        }
        // otherwise, to avoid regression we have to process context length
        ContentRevision beforeRevision = change.getBeforeRevision();
        if (beforeRevision != null) {
            try {
                String content = beforeRevision.getContent();
                if (content == null) {
                    final FilePath file = beforeRevision.getFile();
                    LOG.info("null content for " + (file.getPath()) + ", is dir: " + (file.isDirectory()));
                    continue;
                }
                if (content.length() > VcsConfiguration.ourMaximumFileForBaseRevisionSize) {
                    exclude.add(change);
                }
            } catch (VcsException e) {
                LOG.info(e);
            }
        }
    }
    return exclude;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) VcsException(com.intellij.openapi.vcs.VcsException) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) HashSet(java.util.HashSet)

Example 42 with FilePath

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

the class TextFilePatchInProgress method getNewContentRevision.

public ContentRevision getNewContentRevision() {
    if (FilePatchStatus.DELETED.equals(myStatus))
        return null;
    if (myNewContentRevision == null) {
        myConflicts = null;
        if (FilePatchStatus.ADDED.equals(myStatus)) {
            final FilePath newFilePath = VcsUtil.getFilePath(myIoCurrentBase, false);
            final String content = myPatch.getNewFileText();
            myNewContentRevision = new SimpleContentRevision(content, newFilePath, myPatch.getAfterVersionId());
        } else {
            final FilePath newFilePath = detectNewFilePathForMovedOrModified();
            myNewContentRevision = new LazyPatchContentRevision(myCurrentBase, newFilePath, myPatch.getAfterVersionId(), myPatch);
            if (myCurrentBase != null) {
                ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {

                    public void run() {
                        ((LazyPatchContentRevision) myNewContentRevision).getContent();
                    }
                });
            }
        }
    }
    return myNewContentRevision;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SimpleContentRevision(com.intellij.openapi.vcs.changes.SimpleContentRevision)

Example 43 with FilePath

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

the class ShelvedChange method getChange.

public Change getChange(Project project) {
    // todo unify with
    if (myChange == null) {
        File baseDir = new File(project.getBaseDir().getPath());
        File file = getAbsolutePath(baseDir, myBeforePath);
        FilePath beforePath = VcsUtil.getFilePath(file, false);
        beforePath.refresh();
        ContentRevision beforeRevision = null;
        if (myFileStatus != FileStatus.ADDED) {
            beforeRevision = new CurrentContentRevision(beforePath) {

                @Override
                @NotNull
                public VcsRevisionNumber getRevisionNumber() {
                    return new TextRevisionNumber(VcsBundle.message("local.version.title"));
                }
            };
        }
        ContentRevision afterRevision = null;
        if (myFileStatus != FileStatus.DELETED) {
            FilePath afterPath = VcsUtil.getFilePath(getAbsolutePath(baseDir, myAfterPath), false);
            afterRevision = new PatchedContentRevision(project, beforePath, afterPath);
        }
        myChange = new Change(beforeRevision, afterRevision, myFileStatus);
    }
    return myChange;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with FilePath

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

the class ChangesBrowserFilePathNode method render.

@Override
public void render(final ChangesBrowserNodeRenderer renderer, final boolean selected, final boolean expanded, final boolean hasFocus) {
    final FilePath path = (FilePath) userObject;
    if (path.isDirectory() || !isLeaf()) {
        renderer.append(getRelativePath(path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        if (!isLeaf()) {
            appendCount(renderer);
        }
        renderer.setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON);
    } else {
        if (renderer.isShowFlatten()) {
            renderer.append(path.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
            FilePath parentPath = path.getParentPath();
            renderer.append(spaceAndThinSpace() + FileUtil.getLocationRelativeToUserHome(parentPath.getPresentableUrl()), SimpleTextAttributes.GRAYED_ATTRIBUTES);
        } else {
            renderer.append(getRelativePath(path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
        renderer.setIcon(path.getFileType().getIcon());
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 45 with FilePath

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

the class ChangesBrowserLocallyDeletedNode method getIcon.

@Nullable
private Icon getIcon() {
    Icon result = getUserObject().getAddIcon();
    if (result == null) {
        FilePath filePath = getUserObject().getPath();
        result = filePath.isDirectory() || !isLeaf() ? PlatformIcons.DIRECTORY_CLOSED_ICON : filePath.getFileType().getIcon();
    }
    return result;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Nullable(org.jetbrains.annotations.Nullable)

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