package git4idea.changes;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsOutgoingChangesProvider;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import git4idea.GitBranchesSearcher;
import git4idea.GitUtil;
import git4idea.commands.GitSimpleHandler;

import java.util.Collections;
import java.util.List;

public class GitOutgoingChangesProvider implements VcsOutgoingChangesProvider {
  private final static Logger LOG = Logger.getInstance("#git4idea.changes.GitOutgoingChangesProvider");
  private final Project myProject;

  public GitOutgoingChangesProvider(Project project) {
    myProject = project;
  }

  public List getOutgoingChanges(final VirtualFile vcsRoot, final boolean findRemote) throws VcsException {
    LOG.debug("getOutgoingChanges root: " + vcsRoot.getPath());
    final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, findRemote);
    if (searcher.getLocal() == null || searcher.getRemote() == null) return Collections.emptyList();

    return GitUtil.getLocalCommittedChanges(myProject, vcsRoot, new Consumer<GitSimpleHandler>() {
      public void consume(final GitSimpleHandler handler) {
        handler.addParameters(searcher.getRemote().getFullName() + "..HEAD");
      }
    });
  }
}

@@ -112,16 +112,55 @@
 roject;%0A
+import com.intellij.openapi.util.Pair;%0A
 import c
@@ -253,24 +253,151 @@
 esProvider;%0A
+import com.intellij.openapi.vcs.history.VcsRevisionNumber;%0Aimport com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;%0A
 import com.i
@@ -701,16 +701,37 @@
 Provider
+%3CCommittedChangeList%3E
  %7B%0A  pri
@@ -959,20 +959,66 @@
  public 
-List
+Pair%3CVcsRevisionNumber, List%3CCommittedChangeList%3E%3E
  getOutg
@@ -1339,27 +1339,117 @@
 ll) 
-return Collections.
+%7B%0A      return new Pair%3CVcsRevisionNumber, List%3CCommittedChangeList%3E%3E(null, Collections.%3CCommittedChangeList%3E
 empt
@@ -1459,21 +1459,61 @@
 st()
+)
 ;%0A
-%0A    return
+    %7D%0A%0A    final List%3CCommittedChangeList%3E lists =
  Git
@@ -1751,14 +1751,94 @@
     %7D);%0A
+    return new Pair%3CVcsRevisionNumber, List%3CCommittedChangeList%3E%3E(null, lists);%0A
   %7D%0A%7D%0A

return base vcs revision number in outgoing changes provider (definition only)