Search in sources :

Example 31 with VcsRevisionNumber

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

the class ShowDiffFromAnnotation method correctActualLineIfTextEmpty.

private int correctActualLineIfTextEmpty(@NotNull String[] contentsLines, final int actualLine) {
    final VcsRevisionNumber revision = myFileAnnotation.getLineRevisionNumber(actualLine);
    if (revision == null)
        return actualLine;
    if (!StringUtil.isEmptyOrSpaces(contentsLines[actualLine]))
        return actualLine;
    int upperBound = Math.min(actualLine + ourVicinity, contentsLines.length);
    for (int i = actualLine + 1; i < upperBound; i++) {
        if (revision.equals(myFileAnnotation.getLineRevisionNumber(i)) && !StringUtil.isEmptyOrSpaces(contentsLines[i])) {
            return i;
        }
    }
    int lowerBound = Math.max(actualLine - ourVicinity, 0);
    for (int i = actualLine - 1; i >= lowerBound; --i) {
        if (revision.equals(myFileAnnotation.getLineRevisionNumber(i)) && !StringUtil.isEmptyOrSpaces(contentsLines[i])) {
            return i;
        }
    }
    return actualLine;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 32 with VcsRevisionNumber

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

the class AnnotateDiffViewerAction method createAnnotationsLoader.

@Nullable
private static FileAnnotationLoader createAnnotationsLoader(@NotNull Project project, @NotNull DiffContent content) {
    if (content instanceof FileContent) {
        VirtualFile file = ((FileContent) content).getFile();
        AbstractVcs vcs = VcsUtil.getVcsFor(project, file);
        FileAnnotationLoader loader = doCreateAnnotationsLoader(project, vcs, file);
        if (loader != null)
            return loader;
    }
    Pair<FilePath, VcsRevisionNumber> info = content.getUserData(DiffUserDataKeysEx.REVISION_INFO);
    if (info != null) {
        FilePath filePath = info.first;
        AbstractVcs vcs = VcsUtil.getVcsFor(project, filePath);
        FileAnnotationLoader loader = doCreateAnnotationsLoader(vcs, filePath, info.second);
        if (loader != null)
            return loader;
    }
    return null;
}
Also used : FileContent(com.intellij.diff.contents.FileContent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) Nullable(org.jetbrains.annotations.Nullable)

Example 33 with VcsRevisionNumber

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

the class VcsCurrentRevisionProxy method loadContent.

@NotNull
private Pair<VcsRevisionNumber, byte[]> loadContent() throws VcsException {
    VcsRevisionNumber currentRevision = getCurrentRevisionNumber();
    ContentRevision contentRevision = myDiffProvider.createFileContent(currentRevision, myFile);
    if (contentRevision == null) {
        throw new VcsException("Failed to create content for current revision");
    }
    return Pair.create(currentRevision, contentRevision.getContent().getBytes(myFile.getCharset()));
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 34 with VcsRevisionNumber

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

the class RemoteRevisionsNumbersCache method invalidate.

public void invalidate(final Collection<String> paths) {
    synchronized (myLock) {
        for (String path : paths) {
            final Pair<VcsRoot, VcsRevisionNumber> pair = myData.remove(path);
            if (pair != null) {
                // vcs [root] seems to not change
                final VcsRoot vcsRoot = pair.getFirst();
                final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
                queue.forceRemove(path);
                queue.addRequest(path);
                myData.put(path, Pair.create(vcsRoot, NOT_LOADED));
            }
        }
    }
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsRoot(com.intellij.openapi.vcs.VcsRoot)

Example 35 with VcsRevisionNumber

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

the class BinaryFilePatchInProgress method createChange.

@NotNull
@Override
protected Change createChange(Project project) {
    ContentRevision before = null;
    ContentRevision after = null;
    if (!myPatch.isNewFile()) {
        before = new CurrentBinaryContentRevision(getFilePath()) {

            @NotNull
            @Override
            public VcsRevisionNumber getRevisionNumber() {
                return new TextRevisionNumber(VcsBundle.message("local.version.title"));
            }
        };
    }
    if (!myPatch.isDeletedFile()) {
        after = createNewContentRevision(getFilePath());
    }
    return new Change(before, after);
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) SimpleBinaryContentRevision(com.intellij.openapi.vcs.changes.shelf.SimpleBinaryContentRevision) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)48 VirtualFile (com.intellij.openapi.vfs.VirtualFile)14 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)11 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)7 FilePath (com.intellij.openapi.vcs.FilePath)6 Project (com.intellij.openapi.project.Project)5 VcsException (com.intellij.openapi.vcs.VcsException)4 File (java.io.File)4 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)3 Pair (com.intellij.openapi.util.Pair)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)3 VcsRoot (com.intellij.openapi.vcs.VcsRoot)3 Change (com.intellij.openapi.vcs.changes.Change)3 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)3 HashMap (com.intellij.util.containers.HashMap)3 DiffContent (com.intellij.diff.contents.DiffContent)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2