Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-04-17 18:01:55 +0000
committerMatthias Sohn2013-04-17 23:17:25 +0000
commit7aac348c7ad4ff06c09d1892a4867f0f6059496f (patch)
tree7c71fce6c56dd1096ec98b6070b42dc5dcc528f8
parenta0fb046990eaa2118cb20b86d21dd5dee5002079 (diff)
downloadegit-7aac348c7ad4ff06c09d1892a4867f0f6059496f.tar.gz
egit-7aac348c7ad4ff06c09d1892a4867f0f6059496f.tar.xz
egit-7aac348c7ad4ff06c09d1892a4867f0f6059496f.zip
pull up #getBranchesOfCommit and #getRepository
These two methods can be pulled up to AbstractHistoryCommandHandler Change-Id: I6ef71d0e800142d6b762e7b5b8814e7b716a37be Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java45
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/DeleteBranchOnCommitHandler.java37
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RenameBranchOnCommitHandler.java32
3 files changed, 45 insertions, 69 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
index c0e62c4f86..8f2bde964d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
@@ -37,8 +37,10 @@ import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevWalk;
@@ -225,4 +227,47 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
}
return nodes;
}
+
+ protected List<Ref> getBranchesOfCommit(GitHistoryPage page,
+ final Repository repo, boolean hideCurrentBranch)
+ throws IOException {
+ String head = repo.getFullBranch();
+ return getBranchesOfCommit(page, head, hideCurrentBranch);
+ }
+
+ protected List<Ref> getBranchesOfCommit(GitHistoryPage page) {
+ return getBranchesOfCommit(page, (String) null, false);
+ }
+
+ private List<Ref> getBranchesOfCommit(GitHistoryPage page, String head,
+ boolean hideCurrentBranch) {
+ final List<Ref> branchesOfCommit = new ArrayList<Ref>();
+ IStructuredSelection selection = getSelection(page);
+ if (selection.isEmpty())
+ return branchesOfCommit;
+ PlotCommit commit = (PlotCommit) selection.getFirstElement();
+
+ int refCount = commit.getRefCount();
+ for (int i = 0; i < refCount; i++) {
+ Ref ref = commit.getRef(i);
+ String refName = ref.getName();
+ if (hideCurrentBranch && head != null && refName.equals(head))
+ continue;
+ if (refName.startsWith(Constants.R_HEADS)
+ || refName.startsWith(Constants.R_REMOTES))
+ branchesOfCommit.add(ref);
+ }
+ return branchesOfCommit;
+ }
+
+ protected Repository getRepository(GitHistoryPage page) {
+ if (page == null)
+ return null;
+ HistoryPageInput input = page.getInputInternal();
+ if (input == null)
+ return null;
+
+ final Repository repository = input.getRepository();
+ return repository;
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/DeleteBranchOnCommitHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/DeleteBranchOnCommitHandler.java
index 50cc851c73..4e606e6d0c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/DeleteBranchOnCommitHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/DeleteBranchOnCommitHandler.java
@@ -23,16 +23,12 @@ import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
import org.eclipse.egit.ui.internal.dialogs.UnmergedBranchDialog;
import org.eclipse.egit.ui.internal.history.GitHistoryPage;
-import org.eclipse.egit.ui.internal.history.HistoryPageInput;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
@@ -133,39 +129,6 @@ public class DeleteBranchOnCommitHandler extends AbstractHistoryCommandHandler {
return null;
}
- private List<Ref> getBranchesOfCommit(GitHistoryPage page,
- final Repository repo, boolean hideCurrentBranch) throws IOException {
- final List<Ref> branchesOfCommit = new ArrayList<Ref>();
- IStructuredSelection selection = getSelection(page);
- if (selection.isEmpty())
- return branchesOfCommit;
- PlotCommit commit = (PlotCommit) selection.getFirstElement();
- String head = repo.getFullBranch();
-
- int refCount = commit.getRefCount();
- for (int i = 0; i < refCount; i++) {
- Ref ref = commit.getRef(i);
- String refName = ref.getName();
- if (hideCurrentBranch && head != null && refName.equals(head))
- continue;
- if (refName.startsWith(Constants.R_HEADS)
- || refName.startsWith(Constants.R_REMOTES))
- branchesOfCommit.add(ref);
- }
- return branchesOfCommit;
- }
-
- private Repository getRepository(GitHistoryPage page) {
- if (page == null)
- return null;
- HistoryPageInput input = page.getInputInternal();
- if (input == null)
- return null;
-
- final Repository repository = input.getRepository();
- return repository;
- }
-
private int deleteBranch(Repository repo, final Ref ref, boolean force)
throws CoreException {
DeleteBranchOperation dbop = new DeleteBranchOperation(repo, ref, force);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RenameBranchOnCommitHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RenameBranchOnCommitHandler.java
index 94aecfa736..0bd22a0406 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RenameBranchOnCommitHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RenameBranchOnCommitHandler.java
@@ -8,7 +8,6 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
@@ -17,13 +16,9 @@ import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
import org.eclipse.egit.ui.internal.history.GitHistoryPage;
-import org.eclipse.egit.ui.internal.history.HistoryPageInput;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
@@ -63,33 +58,6 @@ public class RenameBranchOnCommitHandler extends AbstractHistoryCommandHandler {
return null;
}
- private List<Ref> getBranchesOfCommit(GitHistoryPage page) {
- final List<Ref> branchesOfCommit = new ArrayList<Ref>();
- IStructuredSelection selection = getSelection(page);
- if (selection.isEmpty())
- return branchesOfCommit;
- PlotCommit commit = (PlotCommit) selection.getFirstElement();
-
- int refCount = commit.getRefCount();
- for (int i = 0; i < refCount; i++) {
- Ref ref = commit.getRef(i);
- String refName = ref.getName();
- if (refName.startsWith(Constants.R_HEADS)
- || refName.startsWith(Constants.R_REMOTES))
- branchesOfCommit.add(ref);
- }
- return branchesOfCommit;
- }
-
- private Repository getRepository(GitHistoryPage page) {
- if (page == null)
- return null;
- HistoryPageInput input = page.getInputInternal();
- if (input == null)
- return null;
- return input.getRepository();
- }
-
@Override
public boolean isEnabled() {
GitHistoryPage page = getPage();

Back to the top