diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java index abe3006c2ece..e4e4c84cd5cb 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java @@ -42,6 +42,14 @@ public class VcsLogImpl implements VcsLog { myUi = vcsLogManager.getLogUi(); } + /** + * Checks if the log is initialized. + * TODO Temporary method until the old Git log is switched off and removed + */ + public boolean isReady() { + return myDataHolder != null && myUi != null; + } + @NotNull @Override public List getSelectedCommits() { diff --git a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java index 50cf5cf9e8c3..5878c074f229 100644 --- a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java +++ b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java @@ -31,6 +31,7 @@ import com.intellij.vcs.log.Hash; import com.intellij.vcs.log.VcsFullCommitDetails; import com.intellij.vcs.log.VcsLog; import com.intellij.vcs.log.VcsLogObjectsFactory; +import com.intellij.vcs.log.impl.VcsLogImpl; import git4idea.GitLocalBranch; import git4idea.GitPlatformFacade; import git4idea.GitVcs; @@ -174,7 +175,11 @@ public class GitCherryPickAction extends DumbAwareAction { if (project == null) { return null; } - List selectedCommits = getVcsLog(project).getSelectedCommits(); + VcsLog log = getVcsLog(project); + if (log == null) { + return null; + } + List selectedCommits = log.getSelectedCommits(); // don't allow to cherry-pick if a non-Git commit was selected // we could cherry-pick just Git commits filtered from the list, but it might provide confusion boolean nonGitCommitSelected = ContainerUtil.find(selectedCommits, new Condition() { @@ -207,7 +212,8 @@ public class GitCherryPickAction extends DumbAwareAction { } private static VcsLog getVcsLog(@NotNull Project project) { - return ServiceManager.getService(project, VcsLog.class); + VcsLog logService = ServiceManager.getService(project, VcsLog.class); + return logService != null && ((VcsLogImpl)logService).isReady() ? logService : null; } // TODO remove after removing the old Vcs Log implementation @@ -220,7 +226,11 @@ public class GitCherryPickAction extends DumbAwareAction { if (event.getProject() == null) { return null; } - return getVcsLog(event.getProject()).getContainingBranches(commit.getHash()); + VcsLog log = getVcsLog(event.getProject()); + if (log == null) { + return null; + } + return log.getContainingBranches(commit.getHash()); } }