import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
+import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.VcsFileUtil;
import com.intellij.vcsUtil.VcsUtil;
+ import git4idea.branch.GitBranchUtil;
import git4idea.changes.GitChangeUtils;
import git4idea.changes.GitCommittedChangeList;
import git4idea.commands.GitCommand;
}
}
+ /**
+ * Show changes made in the specified revision.
+ *
+ * @param project the project
+ * @param revision the revision number
+ * @param file the file affected by the revision
+ * @param local pass true to let the diff be editable, i.e. making the revision "at the right" be a local (current) revision.
+ * pass false to let both sides of the diff be non-editable.
+ * @param revertable pass true to let "Revert" action be active.
+ */
+ public static void showSubmittedFiles(final Project project, final String revision, final VirtualFile file,
+ final boolean local, final boolean revertable) {
+ new Task.Backgroundable(project, GitBundle.message("changes.retrieving", revision)) {
+ public void run(@NotNull ProgressIndicator indicator) {
+ indicator.setIndeterminate(true);
+ try {
+ VirtualFile vcsRoot = getGitRoot(file);
+ final CommittedChangeList changeList = GitChangeUtils.getRevisionChanges(project, vcsRoot, revision, true, local, revertable);
+ if (changeList != null) {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ public void run() {
+ AbstractVcsHelper.getInstance(project).showChangesListBrowser(changeList,
+ GitBundle.message("paths.affected.title", revision));
+ }
+ });
+ }
+ }
+ catch (final VcsException e) {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ public void run() {
+ GitUIUtil.showOperationError(project, e, "git show");
+ }
+ });
+ }
+ }
+ }.queue();
+ }
+
++
+ /**
+ * Returns the tracking information (remote and the name of the remote branch), or null if we are not on a branch.
+ */
+ @Nullable
+ public static GitBranchTrackInfo getTrackInfoForCurrentBranch(@NotNull GitRepository repository) {
+ GitBranch currentBranch = repository.getCurrentBranch();
+ if (currentBranch == null) {
+ return null;
+ }
+ return GitBranchUtil.getTrackInfoForBranch(repository, currentBranch);
+ }
+
}