Search in sources :

Example 36 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) {
    VcsFileRevision revision = getFileRevision(e);
    if (revision == null)
        return null;
    final FileType currentFileType = myAnnotation.getFile().getFileType();
    FilePath filePath = (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx) revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
    return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {

        @NotNull
        @Override
        public FileType getFileType() {
            FileType type = super.getFileType();
            if (!type.isBinary())
                return type;
            if (!currentFileType.isBinary())
                return currentFileType;
            return PlainTextFileType.INSTANCE;
        }
    };
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsFileRevisionEx(com.intellij.openapi.vcs.history.VcsFileRevisionEx) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with FilePath

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

the class Change method equals.

public boolean equals(final Object o) {
    if (this == o)
        return true;
    if (o == null || (!(o instanceof Change)))
        return false;
    final Change otherChange = ((Change) o);
    final ContentRevision br1 = getBeforeRevision();
    final ContentRevision br2 = otherChange.getBeforeRevision();
    final ContentRevision ar1 = getAfterRevision();
    final ContentRevision ar2 = otherChange.getAfterRevision();
    FilePath fbr1 = br1 != null ? br1.getFile() : null;
    FilePath fbr2 = br2 != null ? br2.getFile() : null;
    FilePath far1 = ar1 != null ? ar1.getFile() : null;
    FilePath far2 = ar2 != null ? ar2.getFile() : null;
    return Comparing.equal(fbr1, fbr2) && Comparing.equal(far1, far2);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 38 with FilePath

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

the class ExternallyRenamedChange method setRenamedOrMovedTarget.

public void setRenamedOrMovedTarget(final FilePath target) {
    myMoved = myRenamed = false;
    if ((getBeforeRevision() != null) || (getAfterRevision() == null)) {
        // not external rename or move
        return;
    }
    final FilePath localPath = ChangesUtil.getFilePath(this);
    if (localPath.getPath().equals(target.getPath())) {
        // not rename or move
        return;
    }
    if (Comparing.equal(target.getParentPath(), localPath.getParentPath())) {
        myRenamed = true;
    } else {
        myMoved = true;
    }
    myCopied = false;
    myRenamedTargetName = target.getName();
    myRenameOrMoveCached = true;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 39 with FilePath

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

the class ApplyPatchContext method registerBeforeRename.

public void registerBeforeRename(final VirtualFile file) {
    FilePath path = VcsUtil.getFilePath(file);
    myPathsBeforeRename.put(file, path);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 40 with FilePath

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

the class IdeaTextPatchBuilder method convertRevisionToAir.

@Nullable
private static AirContentRevision convertRevisionToAir(final ContentRevision cr, final Long ts) {
    if (cr == null)
        return null;
    final FilePath fp = cr.getFile();
    final StaticPathDescription description = new StaticPathDescription(fp.isDirectory(), ts == null ? fp.getIOFile().lastModified() : ts, fp.getPath());
    if (cr instanceof BinaryContentRevision) {
        return new BinaryAirContentRevision((BinaryContentRevision) cr, description, ts);
    } else {
        return new TextAirContentRevision(cr, description, ts);
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) 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