diff options
3 files changed, 34 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index 72dabe4225..2a4c24e487 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -426,6 +426,9 @@ public class UIText extends NLS { public static String GitHistoryPage_CheckoutMenuLabel; /** */ + public static String GitHistoryPage_CheckoutMenuLabel2; + + /** */ public static String GitHistoryPage_CompareModeMenuLabel; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java index 11f8af7cb9..0ce9aa6994 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java @@ -62,6 +62,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revplot.PlotCommit; @@ -764,9 +765,16 @@ class CommitGraphTable { if (selectionSize == 1) { popupMgr.add(new Separator()); - popupMgr.add(getCommandContributionItem( - HistoryViewCommands.CHECKOUT, - UIText.GitHistoryPage_CheckoutMenuLabel)); + if (hasMultipleRefNodes()) { + popupMgr.add(getCommandContributionItem( + HistoryViewCommands.CHECKOUT, + UIText.GitHistoryPage_CheckoutMenuLabel2)); + } else { + popupMgr.add(getCommandContributionItem( + HistoryViewCommands.CHECKOUT, + UIText.GitHistoryPage_CheckoutMenuLabel)); + } + popupMgr.add(getCommandContributionItem( HistoryViewCommands.PUSH_COMMIT, UIText.GitHistoryPage_pushCommit)); @@ -863,6 +871,25 @@ class CommitGraphTable { popupMgr.add(new Separator()); } + private boolean hasMultipleRefNodes() { + try { + Map<String, Ref> branches = input.getRepository() + .getRefDatabase().getRefs(Constants.R_HEADS); + int count = 0; + for (Ref branch : branches.values()) { + if (branch.getLeaf().getObjectId() + .equals(((RevCommit) ((IStructuredSelection) selectionProvider + .getSelection()).getFirstElement()).getId())) + count++; + } + return (count > 1); + + } catch (IOException e) { + // ignore here + } + return false; + } + private CommandContributionItem getCommandContributionItem( String commandId, String menuLabel) { CommandContributionItemParameter parameter = new CommandContributionItemParameter( diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index e61c9a2ab9..f13ab69f07 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -153,6 +153,7 @@ GitHistoryPage_AllInRepoTooltip=Show all changes in repository containing the se GitHistoryPage_AllOfResourceMenuLabel=All &Changes of Resource GitHistoryPage_AllOfResourceTooltip=Show all changes of selected resource and its children GitHistoryPage_CheckoutMenuLabel=&Checkout +GitHistoryPage_CheckoutMenuLabel2=&Checkout... GitHistoryPage_CompareModeMenuLabel=Compare &Mode GitHistoryPage_ReuseCompareEditorMenuLabel=Reuse Compare &Editor GitHistoryPage_CompareWithCurrentHeadMenu=Compare with &HEAD |