Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-10-14 21:27:16 +0000
committerThomas Wolf2016-10-14 21:41:19 +0000
commitc72723a3407f343a40d66532680b1cbcb30d1169 (patch)
tree4b4014d13e966fb52d696c9a343be47d98fed128
parent417bbc5f91fe188550ab948211ffc1cb684b8f50 (diff)
downloadegit-c72723a3407f343a40d66532680b1cbcb30d1169.tar.gz
egit-c72723a3407f343a40d66532680b1cbcb30d1169.tar.xz
egit-c72723a3407f343a40d66532680b1cbcb30d1169.zip
Fix display of "Show Revision Information" in editors
The context menu was missing from editors opened from the history view's file list (Context menu->Show Revision Information would open an editor and show the annotations, but when these were then hidden, they could not be re-displayed from within the editor). Moreover, opening a file version from the history view (Context menu->Open This Version) would open an editor that would have the "Show Revision Information" context menu, but when invoked it would open up yet another editor. The root cause is explained in bug 505938, comment 2. Basically we end up with different FileRevisionEditorInput classes being used for editors, one from EGit, and an internal one from org.eclipse.ui.team. Fix this by refactoring the blame machinery in EGit UI to work either with IFile or with CommitFileRevision. and make sure to use EgitEditorUtils.openEditor() instead of RevisionAnnotationController.openEditor(). Bug: 505938 Change-Id: Ie9d857ee469f93e8df3d8b6cc386c410394ccc29 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java89
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java86
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowBlameHandler.java22
6 files changed, 119 insertions, 123 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java
index 67d41cfc3d..17045c4b82 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.ui.Activator;
@@ -55,14 +56,15 @@ public class EgitUiEditorUtils {
public static IEditorPart openEditor(IWorkbenchPage page,
IFileRevision revision, IProgressMonitor monitor)
throws CoreException {
- IStorage file = revision.getStorage(monitor);
+ SubMonitor progress = SubMonitor.convert(monitor, 2);
+ IStorage file = revision.getStorage(progress.newChild(1));
if (file instanceof IFile) {
// if this is the current workspace file, open it
return IDE.openEditor(page, (IFile) file, OpenStrategy
.activateOnOpen());
} else {
FileRevisionEditorInput fileRevEditorInput = FileRevisionEditorInput
- .createEditorInputFor(revision, monitor);
+ .createEditorInputFor(revision, progress.newChild(1));
IEditorPart part = openEditor(page, fileRevEditorInput);
return part;
}
@@ -83,8 +85,9 @@ public class EgitUiEditorUtils {
public static void openTextEditor(IWorkbenchPage page,
IFileRevision revision, IProgressMonitor monitor)
throws CoreException {
+ SubMonitor progress = SubMonitor.convert(monitor, 1);
FileRevisionEditorInput fileRevEditorInput = FileRevisionEditorInput
- .createEditorInputFor(revision, monitor);
+ .createEditorInputFor(revision, progress.newChild(1));
openEditor(page, fileRevEditorInput, EditorsUI.DEFAULT_TEXT_EDITOR_ID);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
index 0cebf261bc..9c03cb0cfa 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2012 GitHub Inc. and others.
+ * Copyright (c) 2011, 2016 GitHub Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,15 +8,15 @@
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
* François Rey - gracefully ignore linked resources
+ * Thomas Wolf <thomas.wolf@paranor.ch>
*****************************************************************************/
package org.eclipse.egit.ui.internal.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.job.JobUtil;
import org.eclipse.egit.core.internal.storage.CommitFileRevision;
@@ -25,8 +25,6 @@ import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.blame.BlameOperation;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -39,70 +37,47 @@ public class ShowBlameActionHandler extends RepositoryActionHandler {
/** @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
- Data data = getData(getSelection(event));
-
- if (data == null)
- return null;
-
- Repository repository = data.repository;
- String path = data.repositoryRelativePath;
- IStorage storage = data.storage;
- RevCommit startCommit = data.startCommit;
- Shell shell = HandlerUtil.getActiveShell(event);
- IWorkbenchPage page = HandlerUtil.getActiveSite(event).getPage();
- JobUtil.scheduleUserJob(new BlameOperation(repository, storage, path,
- startCommit, shell, page), UIText.ShowBlameHandler_JobName,
- JobFamilies.BLAME);
- return null;
- }
-
- @Override
- public boolean isEnabled() {
- IStructuredSelection selection = getSelection();
- return getData(selection) != null;
- }
-
- private static Data getData(IStructuredSelection selection) {
- if (selection.size() != 1)
+ IStructuredSelection selection = getSelection(event);
+ if (selection.size() != 1) {
return null;
-
+ }
Object element = selection.getFirstElement();
IResource resource = AdapterUtils.adapt(element, IResource.class);
- if (resource instanceof IStorage) {
- IStorage storage = (IStorage) resource;
+ if (resource instanceof IFile) {
RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
-
if (mapping != null) {
String repoRelativePath = mapping.getRepoRelativePath(resource);
- return new Data(mapping.getRepository(), repoRelativePath,
- storage, null);
+ Shell shell = HandlerUtil.getActiveShell(event);
+ IWorkbenchPage page = HandlerUtil.getActiveSite(event)
+ .getPage();
+ JobUtil.scheduleUserJob(
+ new BlameOperation(mapping.getRepository(),
+ (IFile) resource, repoRelativePath, null, shell,
+ page),
+ UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
}
} else if (element instanceof CommitFileRevision) {
- CommitFileRevision revision = (CommitFileRevision) element;
- try {
- IStorage storage = revision.getStorage(new NullProgressMonitor());
- return new Data(revision.getRepository(),
- revision.getGitPath(), storage, revision.getRevCommit());
- } catch (CoreException e) {
- // Don't enable
- return null;
- }
+ Shell shell = HandlerUtil.getActiveShell(event);
+ IWorkbenchPage page = HandlerUtil.getActiveSite(event).getPage();
+ JobUtil.scheduleUserJob(
+ new BlameOperation((CommitFileRevision) element, shell,
+ page),
+ UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
}
return null;
}
- private static class Data {
- private final Repository repository;
- private final String repositoryRelativePath;
- private final IStorage storage;
- private final RevCommit startCommit;
-
- public Data(Repository repository, String repositoryRelativePath,
- IStorage storage, RevCommit startCommit) {
- this.repository = repository;
- this.repositoryRelativePath = repositoryRelativePath;
- this.storage = storage;
- this.startCommit = startCommit;
+ @Override
+ public boolean isEnabled() {
+ IStructuredSelection selection = getSelection();
+ if (selection.size() != 1) {
+ return false;
+ }
+ Object element = selection.getFirstElement();
+ IResource resource = AdapterUtils.adapt(element, IResource.class);
+ if (resource instanceof IStorage) {
+ return RepositoryMapping.getMapping(resource) != null;
}
+ return element instanceof CommitFileRevision;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java
index f4988f4330..ad6411878e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java
@@ -16,10 +16,8 @@ import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.internal.job.JobUtil;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
@@ -459,18 +457,17 @@ public class BlameInformationControl extends AbstractInformationControl
IFileRevision rev = CompareUtils.getFileRevision(path, parent,
revision.getRepository(), null);
int line = sourceLine == null ? -1 : sourceLine.intValue();
- IStorage storage = rev.getStorage(new NullProgressMonitor());
- IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- BlameOperation operation = new BlameOperation(
- revision.getRepository(), storage, path, parent,
- getShell(), page, line);
- JobUtil.scheduleUserJob(operation, UIText.ShowBlameHandler_JobName,
- JobFamilies.BLAME);
+ if (rev instanceof CommitFileRevision) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ BlameOperation operation = new BlameOperation(
+ (CommitFileRevision) rev, getShell(),
+ page, line);
+ JobUtil.scheduleUserJob(operation,
+ UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
+ }
} catch (IOException e) {
Activator.logError(UIText.ShowBlameHandler_errorMessage, e);
- } catch (CoreException e) {
- Activator.logError(UIText.ShowBlameHandler_errorMessage, e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
index d6662f5a66..b9bb591da0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2013 GitHub Inc and others.
+ * Copyright (c) 2011, 2016 GitHub Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - don't use RevisionAnnotationController
*****************************************************************************/
package org.eclipse.egit.ui.internal.blame;
@@ -22,11 +23,14 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.core.op.IEGitOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.egit.ui.internal.EgitUiEditorUtils;
import org.eclipse.egit.ui.internal.history.HistoryPageInput;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -34,6 +38,7 @@ import org.eclipse.jface.text.revisions.IRevisionRulerColumn;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
import org.eclipse.jface.text.revisions.RevisionInformation;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -46,10 +51,10 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.ui.history.IHistoryView;
-import org.eclipse.team.ui.history.RevisionAnnotationController;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
/**
@@ -164,6 +169,8 @@ public class BlameOperation implements IEGitOperation {
private Repository repository;
+ private CommitFileRevision fileRevision;
+
private IStorage storage;
private String path;
@@ -174,7 +181,7 @@ public class BlameOperation implements IEGitOperation {
private IWorkbenchPage page;
- private int lineNumberToReveal;
+ private int lineNumberToReveal = -1;
/**
* Create annotate operation
@@ -186,30 +193,39 @@ public class BlameOperation implements IEGitOperation {
* @param shell
* @param page
*/
- public BlameOperation(Repository repository, IStorage storage, String path,
+ public BlameOperation(Repository repository, IFile storage, String path,
RevCommit startCommit, Shell shell, IWorkbenchPage page) {
- this(repository, storage, path, startCommit, shell, page, -1);
+ this.repository = repository;
+ this.storage = storage;
+ this.path = path;
+ this.startCommit = startCommit;
+ this.shell = shell;
+ this.page = page;
+ this.lineNumberToReveal = -1;
}
/**
- * Create annotate operation
- *
- * @param repository
- * @param storage
- * @param path
- * @param startCommit
+ * @param revision
+ * @param shell
+ * @param page
+ */
+ public BlameOperation(CommitFileRevision revision, Shell shell,
+ IWorkbenchPage page) {
+ this(revision, shell, page, -1);
+ }
+
+ /**
+ * @param revision
* @param shell
* @param page
* @param lineNumberToReveal
- * 0-based line number to reveal, -1 for no reveal
*/
- public BlameOperation(Repository repository, IStorage storage, String path,
- RevCommit startCommit, Shell shell, IWorkbenchPage page,
- int lineNumberToReveal) {
- this.repository = repository;
- this.storage = storage;
- this.path = path;
- this.startCommit = startCommit;
+ public BlameOperation(CommitFileRevision revision, Shell shell,
+ IWorkbenchPage page, int lineNumberToReveal) {
+ this.fileRevision = revision;
+ this.repository = revision.getRepository();
+ this.path = revision.getGitPath();
+ this.startCommit = revision.getRevCommit();
this.shell = shell;
this.page = page;
this.lineNumberToReveal = lineNumberToReveal;
@@ -217,6 +233,7 @@ public class BlameOperation implements IEGitOperation {
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
+ SubMonitor progress = SubMonitor.convert(monitor, 3);
final RevisionInformation info = new RevisionInformation();
final BlameCommand command = new BlameCommand(repository)
@@ -243,6 +260,7 @@ public class BlameOperation implements IEGitOperation {
Activator.error(e1.getMessage(), e1);
return;
}
+ progress.worked(1);
if (result == null)
return;
@@ -283,10 +301,16 @@ public class BlameOperation implements IEGitOperation {
if (previous != null)
previous.register();
+ progress.worked(1);
if (shell.isDisposed()) {
return;
}
+ if (fileRevision != null) {
+ storage = fileRevision.getStorage(progress.newChild(1));
+ } else {
+ progress.worked(1);
+ }
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
@@ -296,22 +320,24 @@ public class BlameOperation implements IEGitOperation {
}
private void openEditor(final RevisionInformation info) {
- AbstractDecoratedTextEditor editor;
+ IEditorPart editorPart;
try {
- if (storage instanceof IFile)
- editor = RevisionAnnotationController.openEditor(page,
- (IFile) storage);
- else
- editor = RevisionAnnotationController.openEditor(page, storage,
- storage);
- } catch (PartInitException e) {
+ if (fileRevision != null) {
+ editorPart = EgitUiEditorUtils.openEditor(page, fileRevision,
+ null);
+ } else {
+ editorPart = IDE.openEditor(page, (IFile) storage,
+ OpenStrategy.activateOnOpen());
+ }
+ } catch (CoreException e) {
Activator.handleError("Error displaying blame annotations", e, //$NON-NLS-1$
false);
return;
}
- if (editor == null)
+ if (!(editorPart instanceof AbstractDecoratedTextEditor)) {
return;
-
+ }
+ AbstractDecoratedTextEditor editor = (AbstractDecoratedTextEditor) editorPart;
// IRevisionRulerColumn would also be possible but using
// IVerticalRulerInfo seems to work in more situations.
IVerticalRulerInfo rulerInfo = AdapterUtils.adapt(editor,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
index 619733740e..2df64af7dc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
@@ -28,6 +28,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.internal.job.JobUtil;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
@@ -501,10 +502,9 @@ public class CommitFileDiffViewer extends TableViewer {
getRepository(),
d.getChange().equals(ChangeType.DELETE) ? d.getBlobs()[0]
: d.getBlobs()[d.getBlobs().length - 1]);
- if (rev != null) {
- BlameOperation op = new BlameOperation(getRepository(),
- rev.getStorage(new NullProgressMonitor()), path,
- commit, window.getShell(), page);
+ if (rev instanceof CommitFileRevision) {
+ BlameOperation op = new BlameOperation((CommitFileRevision) rev,
+ window.getShell(), page);
JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName,
JobFamilies.BLAME);
} else {
@@ -516,9 +516,6 @@ public class CommitFileDiffViewer extends TableViewer {
} catch (IOException e) {
Activator.logError(UIText.GitHistoryPage_openFailed, e);
Activator.showError(UIText.GitHistoryPage_openFailed, null);
- } catch (CoreException e) {
- Activator.logError(UIText.GitHistoryPage_openFailed, e);
- Activator.showError(UIText.GitHistoryPage_openFailed, null);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowBlameHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowBlameHandler.java
index 9471ef5306..816d0337fd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowBlameHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowBlameHandler.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2012 GitHub Inc.
+ * Copyright (c) 2012, 2016 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,10 +16,8 @@ import java.io.IOException;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.internal.job.JobUtil;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
@@ -62,15 +60,15 @@ public class ShowBlameHandler extends AbstractHistoryCommandHandler {
try {
IFileRevision revision = CompareUtils.getFileRevision(path, commit,
repo, null);
- if (revision == null) {
- return null;
+ if (revision instanceof CommitFileRevision) {
+ BlameOperation op = new BlameOperation(
+ (CommitFileRevision) revision,
+ HandlerUtil.getActiveShell(event),
+ page.getSite().getPage());
+ JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName,
+ JobFamilies.BLAME);
}
- IStorage storage = revision.getStorage(new NullProgressMonitor());
- BlameOperation op = new BlameOperation(repo, storage, path, commit,
- HandlerUtil.getActiveShell(event), page.getSite().getPage());
- JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName,
- JobFamilies.BLAME);
- } catch (IOException | CoreException e) {
+ } catch (IOException e) {
Activator.showError(UIText.ShowBlameHandler_errorMessage, e);
}
return null;

Back to the top