Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-07-06 03:30:40 -0400
committerThomas Wolf2019-07-07 14:21:18 -0400
commit16ce6278de965eae48a8a529000fe9fd019000b6 (patch)
treed5804e5663f4a7fbdfffc3d678516f445823f208
parent104d3ecfe02eb771f107fa0b892a2be646aa81ab (diff)
downloadegit-16ce6278de965eae48a8a529000fe9fd019000b6.tar.gz
egit-16ce6278de965eae48a8a529000fe9fd019000b6.tar.xz
egit-16ce6278de965eae48a8a529000fe9fd019000b6.zip
Replace deprecated getRefs() calls
Change-Id: I7f92400ea6b86a812617d2046351e192d7a8f215 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/gerrit/GerritConfigurationPage.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java16
3 files changed, 17 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
index e6341b24f..76e7226a2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
@@ -128,7 +128,8 @@ public class SwitchToMenu extends ContributionItem implements
private boolean hasBranches(Repository repository) {
try {
- return !repository.getRefDatabase().getRefs(Constants.R_HEADS)
+ return !repository.getRefDatabase()
+ .getRefsByPrefix(Constants.R_HEADS)
.isEmpty();
} catch (IOException e) {
Activator.handleError(e.getMessage(), e, true);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/gerrit/GerritConfigurationPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/gerrit/GerritConfigurationPage.java
index b6ea34414..3704d201f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/gerrit/GerritConfigurationPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/gerrit/GerritConfigurationPage.java
@@ -17,6 +17,7 @@ import java.text.MessageFormat;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
+import java.util.stream.Collectors;
import org.eclipse.egit.core.internal.gerrit.GerritUtil;
import org.eclipse.egit.ui.Activator;
@@ -305,11 +306,14 @@ class GerritConfigurationPage extends WizardPage {
UIUtils.<String> addContentProposalToText(textField,
() -> {
try {
+ String prefix = Constants.R_REMOTES + remoteName + '/';
Set<String> sortedSet = new TreeSet<>(
CommonUtils.STRING_ASCENDING_COMPARATOR);
sortedSet.addAll(repository.getRefDatabase()
- .getRefs(Constants.R_REMOTES + remoteName + '/')
- .keySet());
+ .getRefsByPrefix(prefix).stream()
+ .map(ref -> ref.getName()
+ .substring(prefix.length()))
+ .collect(Collectors.toList()));
return sortedSet;
} catch (IOException e) {
return Collections.emptyList();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
index f300a9aa0..dd6fc41b8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
@@ -249,13 +250,14 @@ public class PushToGerritPage extends WizardPage {
private void loadKnownRemoteRefs() {
try {
- Set<String> remotes = repository.getRefDatabase()
- .getRefs(Constants.R_REMOTES).keySet();
- for (String remote : remotes) {
- // these are "origin/master", "origin/xxx"...
- int slashIndex = remote.indexOf('/');
- if (slashIndex > 0 && slashIndex < remote.length() - 1) {
- knownRemoteRefs.add(remote.substring(slashIndex + 1));
+ List<Ref> refs = repository.getRefDatabase()
+ .getRefsByPrefix(Constants.R_REMOTES);
+ for (Ref ref : refs) {
+ String refName = ref.getName()
+ .substring(Constants.R_REMOTES.length());
+ int slashIndex = refName.indexOf('/');
+ if (slashIndex > 0 && slashIndex < refName.length() - 1) {
+ knownRemoteRefs.add(refName.substring(slashIndex + 1));
}
}
} catch (IOException e) {

Back to the top