Search in sources :

Example 1 with SymbolicRefs

use of git4idea.history.browser.SymbolicRefs in project intellij-community by JetBrains.

the class GitCommittedChangeListProvider method getOneList.

@Override
public Pair<CommittedChangeList, FilePath> getOneList(final VirtualFile file, final VcsRevisionNumber number) throws VcsException {
    FilePath filePath = VcsUtil.getFilePath(file);
    final List<GitHeavyCommit> gitCommits = GitHistoryUtils.commitsDetails(myProject, filePath, new SymbolicRefs(), Collections.singletonList(number.asString()));
    if (gitCommits.size() != 1) {
        return null;
    }
    final GitHeavyCommit gitCommit = gitCommits.get(0);
    CommittedChangeList commit = new GitCommittedChangeList(gitCommit.getDescription() + " (" + gitCommit.getShortHash().getString() + ")", gitCommit.getDescription(), gitCommit.getAuthor(), (GitRevisionNumber) number, new Date(gitCommit.getAuthorTime()), gitCommit.getChanges(), assertNotNull(GitVcs.getInstance(myProject)), true);
    final Collection<Change> changes = commit.getChanges();
    if (changes.size() == 1) {
        Change change = changes.iterator().next();
        return Pair.create(commit, ChangesUtil.getFilePath(change));
    }
    for (Change change : changes) {
        if (change.getAfterRevision() != null && FileUtil.filesEqual(filePath.getIOFile(), change.getAfterRevision().getFile().getIOFile())) {
            return Pair.create(commit, filePath);
        }
    }
    final String afterTime = "--after=" + GitUtil.gitTime(gitCommit.getDate());
    final List<VcsFileRevision> history = GitHistoryUtils.history(myProject, filePath, (VirtualFile) null, afterTime);
    if (history.isEmpty()) {
        return Pair.create(commit, filePath);
    }
    return Pair.create(commit, ((GitFileRevision) history.get(history.size() - 1)).getPath());
}
Also used : SymbolicRefs(git4idea.history.browser.SymbolicRefs) GitHeavyCommit(git4idea.history.browser.GitHeavyCommit) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Change(com.intellij.openapi.vcs.changes.Change) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Aggregations

Change (com.intellij.openapi.vcs.changes.Change)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1 CommittedChangeList (com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)1 GitHeavyCommit (git4idea.history.browser.GitHeavyCommit)1 SymbolicRefs (git4idea.history.browser.SymbolicRefs)1