Search in sources :

Example 41 with VcsRevisionNumber

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

the class SvnDiffProvider method getCurrentRevisions.

@NotNull
@Override
public Map<VirtualFile, VcsRevisionNumber> getCurrentRevisions(@NotNull Iterable<VirtualFile> files) {
    Map<VirtualFile, VcsRevisionNumber> result = ContainerUtil.newHashMap();
    Map<String, VirtualFile> items = ContainerUtil.newHashMap();
    List<File> ioFiles = ContainerUtil.newArrayList();
    for (VirtualFile file : files) {
        File ioFile = VfsUtilCore.virtualToIoFile(file);
        ioFiles.add(ioFile);
        items.put(ioFile.getAbsolutePath(), file);
        // process in blocks of BATCH_INFO_SIZE size
        if (items.size() == BATCH_INFO_SIZE) {
            collectRevisionsInBatch(result, items, ioFiles);
            items.clear();
            ioFiles.clear();
        }
    }
    // process left files
    collectRevisionsInBatch(result, items, ioFiles);
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with VcsRevisionNumber

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

the class GitAnnotationProvider method loadFileHistoryInBackground.

private void loadFileHistoryInBackground(@NotNull GitFileAnnotation fileAnnotation) {
    List<VcsFileRevision> fileRevisions = BackgroundTaskUtil.computeInBackgroundAndTryWait(() -> {
        try {
            VirtualFile file = fileAnnotation.getFile();
            FilePath filePath = VcsUtil.getFilePath(file);
            VcsRevisionNumber currentRevision = fileAnnotation.getCurrentRevision();
            if (file.isInLocalFileSystem() || currentRevision == null) {
                return loadFileHistory(filePath);
            } else {
                return GitHistoryUtils.history(myProject, filePath, null, currentRevision);
            }
        } catch (VcsException e) {
            LOG.error(e);
            return null;
        }
    }, (revisions) -> {
        if (revisions == null)
            return;
        ApplicationManager.getApplication().invokeLater(() -> {
            GitFileAnnotation newFileAnnotation = new GitFileAnnotation(fileAnnotation);
            newFileAnnotation.setRevisions(revisions);
            fileAnnotation.reload(newFileAnnotation);
        }, myProject.getDisposed());
    }, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
    if (fileRevisions != null) {
        fileAnnotation.setRevisions(fileRevisions);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) VcsException(com.intellij.openapi.vcs.VcsException) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 43 with VcsRevisionNumber

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

the class GitFileAnnotation method getRevisionsOrderProvider.

@Nullable
@Override
public RevisionsOrderProvider getRevisionsOrderProvider() {
    ContainerUtil.KeyOrderedMultiMap<Date, VcsRevisionNumber> dates = new ContainerUtil.KeyOrderedMultiMap<>();
    for (int i = 0; i < getLineCount(); i++) {
        LineInfo lineInfo = getLineInfo(i);
        if (lineInfo == null)
            continue;
        VcsRevisionNumber number = lineInfo.getRevisionNumber();
        Date date = lineInfo.getDate();
        dates.putValue(date, number);
    }
    List<List<VcsRevisionNumber>> orderedRevisions = new ArrayList<>();
    NavigableSet<Date> orderedDates = dates.navigableKeySet();
    for (Date date : orderedDates.descendingSet()) {
        Collection<VcsRevisionNumber> revisionNumbers = dates.get(date);
        orderedRevisions.add(new ArrayList<>(revisionNumbers));
    }
    return () -> orderedRevisions;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ContainerUtil(com.intellij.util.containers.ContainerUtil) Nullable(org.jetbrains.annotations.Nullable)

Example 44 with VcsRevisionNumber

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

the class CopyRevisionNumberAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    List<VcsRevisionNumber> revisions = getRevisionNumbersFromContext(e);
    // we want hashes from old to new, e.g. to be able to pass to native client in terminal
    revisions = ContainerUtil.reverse(revisions);
    CopyPasteManager.getInstance().setContents(new StringSelection(getHashesAsString(revisions)));
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) StringSelection(java.awt.datatransfer.StringSelection)

Example 45 with VcsRevisionNumber

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

the class ShelvedBinaryFile method createChange.

public Change createChange(final Project project) {
    ContentRevision before = null;
    ContentRevision after = null;
    final File baseDir = new File(project.getBaseDir().getPath());
    if (BEFORE_PATH != null) {
        final FilePath file = VcsUtil.getFilePath(new File(baseDir, BEFORE_PATH), false);
        before = new CurrentBinaryContentRevision(file) {

            @NotNull
            @Override
            public VcsRevisionNumber getRevisionNumber() {
                return new TextRevisionNumber(VcsBundle.message("local.version.title"));
            }
        };
    }
    if (AFTER_PATH != null) {
        final FilePath file = VcsUtil.getFilePath(new File(baseDir, AFTER_PATH), false);
        after = new ShelvedBinaryContentRevision(file, SHELVED_PATH);
    }
    return new Change(before, after);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) TextRevisionNumber(com.intellij.openapi.vcs.changes.TextRevisionNumber) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) CurrentBinaryContentRevision(com.intellij.openapi.vcs.changes.CurrentBinaryContentRevision) CurrentBinaryContentRevision(com.intellij.openapi.vcs.changes.CurrentBinaryContentRevision) Change(com.intellij.openapi.vcs.changes.Change) File(java.io.File) 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