Comparing two commits is disabled on a none-file resource until we implement the structured compare interfaces. Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- org.spearce.egit.core/META-INF/MANIFEST.MF | 3 ++- .../egit/core/internal/mapping/GitFileHistory.java | 2 +- org.spearce.egit.ui/plugin.xml | 21 ++++++++++++-------- .../src/org/spearce/egit/ui/GitHistoryPage.java | 3 +++ .../org/spearce/egit/ui/GitHistoryPageSource.java | 5 ++++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/org.spearce.egit.core/META-INF/MANIFEST.MF b/org.spearce.egit.core/META-INF/MANIFEST.MF index a8349a1..13ec59d 100644 --- a/org.spearce.egit.core/META-INF/MANIFEST.MF +++ b/org.spearce.egit.core/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.spearce.jgit, org.eclipse.core.filesystem -Export-Package: org.spearce.egit.core.op, +Export-Package: org.spearce.egit.core.internal.mapping;x-friends:="org.spearce.egit.ui", + org.spearce.egit.core.op, org.spearce.egit.core.project Eclipse-LazyStart: true diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java index 6c40bb0..2e4e4e9 100644 --- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java +++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java @@ -158,7 +158,7 @@ public class GitFileHistory extends FileHistory { } } - if (!currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1])) + if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1])) ret.add(new GitFileRevision(previous, resource)); lastResourceHash = currentResourceHash; diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml index d373d18..d81a0b6 100644 --- a/org.spearce.egit.ui/plugin.xml +++ b/org.spearce.egit.ui/plugin.xml @@ -50,7 +50,19 @@ tooltip="%TrackAction_tooltip" menubarPath="team.main/group1" id="org.spearce.egit.ui.internal.actions.Track"/> - </objectContribution> + <action + class="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction" + id="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction" + label="%ShowResourceInHistoryAction_label" + menubarPath="team.main/group1" + tooltip="%ShowResourceInHistoryAction_tooltip"/> + <action + class="org.spearce.egit.ui.internal.actions.GitCompareRevisionAction" + id="org.spearce.egit.ui.internal.actions.GitCompareAction" + menubarPath="team.main/group1" + label="Structured Git Compare"> + </action> + </objectContribution> <objectContribution objectClass="org.eclipse.core.resources.IFile" adaptable="true" @@ -68,13 +80,6 @@ overrideActionId="org.eclipse.team.ui.compareLocalHistory" tooltip="%CompareWithRevisionAction_tooltip"> </action> - <action - class="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction" - enablesFor="1" - id="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction" - label="%ShowResourceInHistoryAction_label" - menubarPath="team.main/group1" - tooltip="%ShowResourceInHistoryAction_tooltip"/> </objectContribution> </extension> diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java index 0e53036..cd31f18 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java @@ -62,6 +62,7 @@ import org.eclipse.team.internal.ui.history.DialogHistoryPageSite; import org.eclipse.team.ui.history.HistoryPage; import org.eclipse.team.ui.history.IHistoryCompareAdapter; import org.eclipse.team.ui.history.IHistoryPageSite; +import org.spearce.egit.core.internal.mapping.GitFileRevision; public class GitHistoryPage extends HistoryPage implements IAdaptable, IHistoryCompareAdapter { @@ -115,6 +116,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable, compareAction.setCurrentFileRevision(fileRevisions[0]); compareAction.selectionChanged(new StructuredSelection( selection2)); + + compareAction.setEnabled(selection!=null && selection[0]!=null && ((GitFileRevision)fileRevisions[0]).getResource().getType() == IResource.FILE); } }); compareAction.setPage(this); diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java index 03c1896..2d56063 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java @@ -27,7 +27,10 @@ public class GitHistoryPageSource extends HistoryPageSource { } public boolean canShowHistoryFor(Object object) { - return (object instanceof IResource && ((IResource) object).getType() == IResource.FILE); + return (object instanceof IResource + && (((IResource) object).getType() == IResource.FILE + || ((IResource) object).getType() == IResource.FOLDER + || ((IResource) object).getType() == IResource.PROJECT)); } } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html