aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-04-25 01:44:43 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-04-25 03:28:51 +0200
commit9edf9bf2d6fd248daf2157bc8245142e5d51f7c2 (patch)
treebde5d20cc6858d47587afd8594ddf8c77675dde1 /org.eclipse.jgit.pgm
parentf26d6558f865cb6a64d0996c534a858310e8b9bb (diff)
downloadjgit-9edf9bf2d6fd248daf2157bc8245142e5d51f7c2.tar.gz
jgit-9edf9bf2d6fd248daf2157bc8245142e5d51f7c2.zip
Remove trivial cases of using deprecated RefDatabase.getRefs()
Change-Id: I2d3e426a3391923f8a690ac68fcc33851f3eb419 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java5
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java7
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java13
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java6
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java2
5 files changed, 14 insertions, 19 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
index 21adf738e0..8ba533f130 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
@@ -49,7 +49,6 @@ import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
@@ -74,8 +73,8 @@ class RevParse extends TextBuiltin {
@Override
protected void run() throws Exception {
if (all) {
- Map<String, Ref> allRefs = db.getRefDatabase().getRefs(ALL);
- for (final Ref r : allRefs.values()) {
+ List<Ref> allRefs = db.getRefDatabase().getRefsByPrefix(ALL);
+ for (final Ref r : allRefs) {
ObjectId objectId = r.getObjectId();
// getRefs skips dangling symrefs, so objectId should never be
// null.
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
index 3fc91013ac..f3714d8d75 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
@@ -47,7 +47,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
-import java.util.Map;
import org.eclipse.jgit.diff.DiffConfig;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
@@ -171,9 +170,9 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
walk.setRevFilter(AndRevFilter.create(revLimiter));
if (all) {
- Map<String, Ref> refs =
- db.getRefDatabase().getRefs(RefDatabase.ALL);
- for (Ref a : refs.values()) {
+ List<Ref> refs =
+ db.getRefDatabase().getRefsByPrefix(RefDatabase.ALL);
+ for (Ref a : refs) {
ObjectId oid = a.getPeeledObjectId();
if (oid == null)
oid = a.getObjectId();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
index 7b59d437ac..2ed5de5c58 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
@@ -48,13 +48,11 @@ package org.eclipse.jgit.pgm;
import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.IOException;
-import java.util.Map;
-import java.util.SortedMap;
+import java.util.List;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefComparator;
-import org.eclipse.jgit.util.RefMap;
@Command(usage = "usage_ShowRef")
class ShowRef extends TextBuiltin {
@@ -69,11 +67,10 @@ class ShowRef extends TextBuiltin {
}
private Iterable<Ref> getSortedRefs() throws Exception {
- Map<String, Ref> all = db.getRefDatabase().getRefs(ALL);
- if (all instanceof RefMap
- || (all instanceof SortedMap && ((SortedMap) all).comparator() == null))
- return all.values();
- return RefComparator.sort(all.values());
+ List<Ref> all = db.getRefDatabase().getRefsByPrefix(ALL);
+ // TODO(jrn) check if we can reintroduce fast-path by e.g. implementing
+ // SortedList
+ return RefComparator.sort(all);
}
private void show(final AnyObjectId id, final String name)
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
index 2e41eec7cb..d7503ab297 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
@@ -117,7 +117,7 @@ class RebuildCommitGraph extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- if (!really && !db.getRefDatabase().getRefs(ALL).isEmpty()) {
+ if (!really && !db.getRefDatabase().getRefsByPrefix(ALL).isEmpty()) {
File directory = db.getDirectory();
String absolutePath = directory == null ? "null" //$NON-NLS-1$
: directory.getAbsolutePath();
@@ -247,8 +247,8 @@ class RebuildCommitGraph extends TextBuiltin {
private void deleteAllRefs() throws Exception {
final RevWalk rw = new RevWalk(db);
- Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL);
- for (final Ref r : refs.values()) {
+ List<Ref> refs = db.getRefDatabase().getRefsByPrefix(ALL);
+ for (final Ref r : refs) {
if (Constants.HEAD.equals(r.getName()))
continue;
final RefUpdate u = db.updateRef(r.getName());
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
index 3172483953..45fbc2cb3c 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
@@ -154,7 +154,7 @@ class RebuildRefTree extends TextBuiltin {
head));
}
- for (Ref r : refdb.getRefs(RefDatabase.ALL).values()) {
+ for (Ref r : refdb.getRefsByPrefix(RefDatabase.ALL)) {
if (r.getName().equals(txnCommitted) || r.getName().equals(HEAD)
|| r.getName().startsWith(txnNamespace)) {
continue;