/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.vcs.log.ui.actions.history;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsLogDiffHandler;
import com.intellij.vcs.log.history.FileHistoryUi;
import com.intellij.vcs.log.ui.VcsLogInternalDataKeys;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ShowDiffAfterWithLocalFromHistoryActionProvider extends FileHistorySingleCommitAction implements AnActionExtensionProvider {
  @Override
  public boolean isActive(@NotNull AnActionEvent e) {
    return e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI) != null;
  }

  @Override
  protected boolean isEnabled(@NotNull FileHistoryUi ui, @Nullable VcsFullCommitDetails detail, @NotNull AnActionEvent e) {
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    VcsLogDiffHandler handler = e.getData(VcsLogInternalDataKeys.LOG_DIFF_HANDLER);

    return filePath != null && filePath.getVirtualFile() != null && handler != null;
  }

  @Override
  protected void performAction(@NotNull Project project,
                               @NotNull FileHistoryUi ui,
                               @NotNull VcsFullCommitDetails detail,
                               @NotNull AnActionEvent e) {
    if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return;

    FilePath path = e.getRequiredData(VcsDataKeys.FILE_PATH);
    VcsLogDiffHandler handler = e.getRequiredData(VcsLogInternalDataKeys.LOG_DIFF_HANDLER);

    handler.showDiffWithLocal(detail.getRoot(), ui.getPathInCommit(detail.getId()), detail.getId(), path);
  }
}

@@ -764,24 +764,81 @@
 onProvider;%0A
+import com.intellij.openapi.actionSystem.CommonDataKeys;%0A
 import com.i
@@ -1044,36 +1044,24 @@
 vcs.log.
-VcsFullCommitDetails
+CommitId
 ;%0Aimport
@@ -1203,24 +1203,69 @@
 alDataKeys;%0A
+import com.intellij.vcs.log.util.VcsLogUtil;%0A
 import org.j
@@ -1298,49 +1298,155 @@
 ll;%0A
+%0A
 import 
-org.jetbrains.annotations.Nullable
+java.util.List;%0A%0Aimport static com.intellij.util.ObjectUtils.notNull;%0Aimport static com.intellij.util.containers.ContainerUtil.getFirstItem
 ;%0A%0Ap
@@ -1509,46 +1509,8 @@
 der 
-extends FileHistorySingleCommitAction 
 impl
@@ -1704,128 +1704,488 @@
 %0A  p
-rotected boolean isEnabled(@NotNull FileHistoryUi ui, @Nullable VcsFullCommitDetails detail, @NotNull AnActionEvent e) %7B
+ublic void update(@NotNull AnActionEvent e) %7B%0A    Project project = e.getProject();%0A    FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI);%0A    if (project == null %7C%7C ui == null) %7B%0A      e.getPresentation().setEnabledAndVisible(false);%0A      return;%0A    %7D%0A%0A    e.getPresentation().setVisible(true);%0A%0A    List%3CCommitId%3E commits = ui.getVcsLog().getSelectedCommits();%0A    if (commits.size() != 1) %7B%0A      e.getPresentation().setEnabled(false);%0A      return;%0A    %7D%0A
 %0A   
@@ -2328,23 +2328,47 @@
 );%0A%0A    
-return 
+e.getPresentation().setEnabled(
 filePath
@@ -2423,32 +2423,33 @@
  handler != null
+)
 ;%0A  %7D%0A%0A  @Overri
@@ -2458,247 +2458,401 @@
 %0A  p
-rotected void performAction(@NotNull Project project,%0A                               @NotNull FileHistoryUi ui,%0A                               @NotNull VcsFullCommitDetails detail,%0A                               @NotNull AnActionEvent e) %7B
+ublic void actionPerformed(@NotNull AnActionEvent e) %7B%0A    VcsLogUtil.triggerUsage(e);%0A%0A    Project project = e.getRequiredData(CommonDataKeys.PROJECT);%0A    FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);%0A%0A    List%3CCommitId%3E commits = ui.getVcsLog().getSelectedCommits();%0A    if (commits.size() != 1) return;%0A    CommitId commit = notNull(getFirstItem(commits));%0A
 %0A   
@@ -3122,22 +3122,22 @@
 thLocal(
-detail
+commit
 .getRoot
@@ -3163,37 +3163,41 @@
 mit(
-detail.getId()), detail.getId
+commit.getHash()), commit.getHash
 (), 

replace VcsCommitMetadata in "Compare with Local" action with CommitId