Merge removal of the "get branches" button from fix_for_121
authorKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Fri, 14 Sep 2012 07:11:30 +0000 (11:11 +0400)
committerKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Fri, 14 Sep 2012 07:11:30 +0000 (11:11 +0400)
Conflicts:
plugins/git4idea/src/git4idea/GitUtil.java
plugins/git4idea/src/git4idea/util/GitUIUtil.java
Simple conflicts: insertion of new methods at the same place, etc.

1  2 
plugins/git4idea/src/git4idea/GitUtil.java
plugins/git4idea/src/git4idea/util/GitUIUtil.java

index 5628715c036273c8eda17ddc782b3d4e4a1bcb9f,9a6d211160bd095932d99fda649392c83c23968b..5b10f51cf0c25412120efd21c1aea89c5ea1edc3
@@@ -36,9 -32,9 +36,10 @@@ import com.intellij.openapi.vfs.LocalFi
  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;
@@@ -872,42 -868,16 +874,55 @@@ public class GitUtil 
      }
    }
  
 +  /**
 +   * 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);
+   }
  }