Search in sources :

Example 6 with VcsRevisionNumber

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

the class RemoteRevisionsNumbersCache method getRevisionState.

/**
   * Returns {@code true} if passed revision is up to date, comparing to latest repository revision.
   */
private boolean getRevisionState(final ContentRevision revision) {
    if (revision != null) {
        // TODO: Seems peg revision should also be tracked here.
        final VcsRevisionNumber local = revision.getRevisionNumber();
        final String path = revision.getFile().getPath();
        final VcsRevisionNumber remote = getNumber(path);
        return NOT_LOADED == remote || UNKNOWN == remote || local.compareTo(remote) >= 0;
    }
    return true;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 7 with VcsRevisionNumber

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

the class RemoteRevisionsNumbersCache method plus.

public void plus(final Pair<String, AbstractVcs> pair) {
    // does not support
    if (pair.getSecond().getDiffProvider() == null)
        return;
    final String key = pair.getFirst();
    final AbstractVcs newVcs = pair.getSecond();
    final VirtualFile root = getRootForPath(key);
    if (root == null)
        return;
    final VcsRoot vcsRoot = new VcsRoot(newVcs, root);
    synchronized (myLock) {
        final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
        if (value == null) {
            final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
            myData.put(key, Pair.create(vcsRoot, NOT_LOADED));
            queue.addRequest(key);
        } else if (!value.getFirst().equals(vcsRoot)) {
            switchVcs(value.getFirst(), vcsRoot, key);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 8 with VcsRevisionNumber

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

the class VcsAnnotationLocalChangesListenerImpl method processUnderFile.

private void processUnderFile(VirtualFile file) {
    final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>();
    synchronized (myLock) {
        for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) {
            if (VfsUtilCore.isAncestor(file, virtualFile, true)) {
                final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile);
                for (FileAnnotation value : values) {
                    annotations.putValue(virtualFile, value);
                }
            }
        }
    }
    if (!annotations.isEmpty()) {
        for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) {
            final VirtualFile key = entry.getKey();
            final VcsRevisionNumber number = fromDiffProvider(key);
            if (number == null)
                continue;
            final Collection<FileAnnotation> fileAnnotations = entry.getValue();
            for (FileAnnotation annotation : fileAnnotations) {
                if (annotation.isBaseRevisionChanged(number)) {
                    annotation.close();
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) MultiMap(com.intellij.util.containers.MultiMap)

Example 9 with VcsRevisionNumber

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

the class HistoryIdColumn method getLineText.

@Override
public String getLineText(int line, Editor editor) {
    if (!isAvailable())
        return "";
    final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(line);
    if (revisionNumber != null) {
        final Integer num = myHistoryIds.get(revisionNumber);
        if (num != null) {
            final String size = String.valueOf(myHistoryIds.size());
            String value = num.toString();
            while (value.length() < size.length()) {
                value = " " + value;
            }
            return value;
        }
    }
    return "";
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 10 with VcsRevisionNumber

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

the class ShowDiffFromAnnotation method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final int actualNumber = currentLine;
    if (actualNumber < 0)
        return;
    final VcsRevisionNumber revisionNumber = myFileAnnotation.getLineRevisionNumber(actualNumber);
    if (revisionNumber != null) {
        final VcsException[] exc = new VcsException[1];
        final List<Change> changes = new LinkedList<>();
        final FilePath[] targetPath = new FilePath[1];
        ProgressManager.getInstance().run(new Task.Backgroundable(myVcs.getProject(), "Loading revision " + revisionNumber.asString() + " contents", true) {

            @Override
            public void run(@NotNull ProgressIndicator indicator) {
                final CommittedChangesProvider provider = myVcs.getCommittedChangesProvider();
                try {
                    final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(myFile, revisionNumber);
                    if (pair == null || pair.getFirst() == null) {
                        VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not load data for show diff", MessageType.ERROR);
                        return;
                    }
                    targetPath[0] = pair.getSecond() == null ? VcsUtil.getFilePath(myFile) : pair.getSecond();
                    final CommittedChangeList cl = pair.getFirst();
                    changes.addAll(cl.getChanges());
                    Collections.sort(changes, ChangesComparator.getInstance(true));
                } catch (VcsException e1) {
                    exc[0] = e1;
                }
            }

            @Override
            public void onSuccess() {
                if (exc[0] != null) {
                    VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not show diff: " + exc[0].getMessage(), MessageType.ERROR);
                } else if (!changes.isEmpty()) {
                    int idx = findSelfInList(changes, targetPath[0]);
                    final ShowDiffContext context = new ShowDiffContext(DiffDialogHints.FRAME);
                    if (idx != -1) {
                        context.putChangeContext(changes.get(idx), DiffUserDataKeysEx.NAVIGATION_CONTEXT, createDiffNavigationContext(actualNumber));
                    }
                    if (ChangeListManager.getInstance(myVcs.getProject()).isFreezedWithNotification(null))
                        return;
                    ShowDiffAction.showDiffForChange(myVcs.getProject(), changes, idx, context);
                }
            }
        });
    }
}
Also used : Task(com.intellij.openapi.progress.Task) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) ShowDiffContext(com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext) Change(com.intellij.openapi.vcs.changes.Change) LinkedList(java.util.LinkedList) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) Pair(com.intellij.openapi.util.Pair)

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