Search in sources :

Example 21 with VcsRevisionNumber

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

the class GitAnnotationProvider method annotate.

@NotNull
public FileAnnotation annotate(@NotNull final VirtualFile file, @Nullable final VcsFileRevision revision) throws VcsException {
    if (file.isDirectory()) {
        throw new VcsException("Cannot annotate a directory");
    }
    final FilePath currentFilePath = VcsUtil.getFilePath(file.getPath());
    final FilePath realFilePath;
    if (revision == null) {
        realFilePath = GitHistoryUtils.getLastCommitName(myProject, currentFilePath);
    } else {
        realFilePath = ((VcsFileRevisionEx) revision).getPath();
    }
    VcsRevisionNumber revisionNumber = revision != null ? revision.getRevisionNumber() : null;
    return annotate(realFilePath, revisionNumber, file);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsException(com.intellij.openapi.vcs.VcsException) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with VcsRevisionNumber

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

the class GitShowCommitInLogAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final Project project = event.getRequiredData(CommonDataKeys.PROJECT);
    final VcsRevisionNumber revision = getRevisionNumber(event);
    if (revision == null) {
        return;
    }
    boolean logReady = findLog(project) != null;
    final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    ContentManager cm = window.getContentManager();
    Content[] contents = cm.getContents();
    for (Content content : contents) {
        if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) {
            cm.setSelectedContent(content);
            break;
        }
    }
    final VcsLog log = findLog(project);
    if (log == null) {
        showLogNotReadyMessage(project);
        return;
    }
    Runnable selectAndOpenLog = new Runnable() {

        @Override
        public void run() {
            Runnable selectCommit = new Runnable() {

                @Override
                public void run() {
                    jumpToRevisionUnderProgress(project, log, revision);
                }
            };
            if (!window.isVisible()) {
                window.activate(selectCommit, true);
            } else {
                selectCommit.run();
            }
        }
    };
    if (logReady) {
        selectAndOpenLog.run();
        return;
    }
    VcsProjectLog projectLog = VcsProjectLog.getInstance(project);
    if (projectLog == null) {
        showLogNotReadyMessage(project);
        return;
    }
    VcsLogUiImpl logUi = projectLog.getMainLogUi();
    if (logUi == null) {
        showLogNotReadyMessage(project);
        return;
    }
    logUi.invokeOnChange(selectAndOpenLog);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) VcsLog(com.intellij.vcs.log.VcsLog) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) ContentManager(com.intellij.ui.content.ContentManager) VcsProjectLog(com.intellij.vcs.log.impl.VcsProjectLog) VcsLogUiImpl(com.intellij.vcs.log.ui.VcsLogUiImpl)

Example 23 with VcsRevisionNumber

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

the class MergeUtil method putRevisionInfo.

private static void putRevisionInfo(@NotNull List<? extends DiffContent> contents, @NotNull MergeData data) {
    for (ThreeSide side : ThreeSide.values()) {
        DiffContent content = side.select(contents);
        FilePath filePath = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH);
        VcsRevisionNumber revision = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER, data.LAST_REVISION_NUMBER);
        if (filePath != null && revision != null) {
            content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(filePath, revision));
        }
    }
}
Also used : ThreeSide(com.intellij.diff.util.ThreeSide) FilePath(com.intellij.openapi.vcs.FilePath) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) DiffContent(com.intellij.diff.contents.DiffContent)

Example 24 with VcsRevisionNumber

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

the class FileGroup method getFilesAndRevisions.

public List<Pair<String, VcsRevisionNumber>> getFilesAndRevisions(ProjectLevelVcsManager vcsManager) {
    ArrayList<Pair<String, VcsRevisionNumber>> files = new ArrayList<>();
    for (UpdatedFile file : myFiles) {
        VcsRevisionNumber number = getRevision(vcsManager, file);
        files.add(Pair.create(file.getPath(), number));
    }
    return files;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 25 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