Browse Source

RefCursor: Remove unnecessary getUpdateIndex method

Now the reference carries its updateIndex, so the cursor doesn't need
to expose it.

Change-Id: Icbfca46f92a13f3d8215ad10b2a166a6f40b0b0f
Signed-off-by: Ivan Frade <ifrade@google.com>
stable-5.3
Ivan Frade 6 years ago
parent
commit
3381bf7e6a
  1. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/MergedReftableTest.java
  2. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableCompactorTest.java
  3. 1
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java
  4. 9
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java
  5. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/RefCursor.java
  6. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableCompactor.java
  7. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/MergedReftableTest.java

@ -316,19 +316,16 @@ public class MergedReftableTest {
assertEquals("refs/heads/a", rc.getRef().getName());
assertEquals(id(1), rc.getRef().getObjectId());
assertEquals(1, rc.getRef().getUpdateIndex());
assertEquals(1, rc.getUpdateIndex());
assertTrue(rc.next());
assertEquals("refs/heads/b", rc.getRef().getName());
assertEquals(id(2), rc.getRef().getObjectId());
assertEquals(2, rc.getRef().getUpdateIndex());
assertEquals(2, rc.getUpdateIndex());
assertTrue(rc.next());
assertEquals("refs/heads/c", rc.getRef().getName());
assertEquals(id(3), rc.getRef().getObjectId());
assertEquals(3, rc.getRef().getUpdateIndex());
assertEquals(3, rc.getUpdateIndex());
}
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableCompactorTest.java

@ -109,7 +109,6 @@ public class ReftableCompactorTest {
assertEquals(MASTER, rc.getRef().getName());
assertEquals(id(1), rc.getRef().getObjectId());
assertEquals(0, rc.getRef().getUpdateIndex());
assertEquals(0, rc.getUpdateIndex());
}
}
@ -157,7 +156,6 @@ public class ReftableCompactorTest {
assertEquals(MASTER, rc.getRef().getName());
assertEquals(id(2), rc.getRef().getObjectId());
assertEquals(1, rc.getRef().getUpdateIndex());
assertEquals(1, rc.getUpdateIndex());
}
}
@ -206,13 +204,11 @@ public class ReftableCompactorTest {
assertEquals(MASTER, rc.getRef().getName());
assertEquals(id(3), rc.getRef().getObjectId());
assertEquals(1, rc.getRef().getUpdateIndex());
assertEquals(1, rc.getUpdateIndex());
assertTrue(rc.next());
assertEquals(NEXT, rc.getRef().getName());
assertEquals(id(2), rc.getRef().getObjectId());
assertEquals(0, rc.getRef().getUpdateIndex());
assertEquals(0, rc.getUpdateIndex());
}
}

1
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java

@ -443,7 +443,6 @@ public class ReftableTest {
assertEquals(MASTER, rc.getRef().getName());
assertEquals(id(1), rc.getRef().getObjectId());
assertEquals(1, rc.getRef().getUpdateIndex());
assertEquals(1, rc.getUpdateIndex());
assertTrue(rc.next());
assertEquals(NEXT, rc.getRef().getName());

9
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java

@ -168,7 +168,6 @@ public class MergedReftable extends Reftable {
private final PriorityQueue<RefQueueEntry> queue;
private RefQueueEntry head;
private Ref ref;
private long updateIndex;
MergedRefCursor() {
queue = new PriorityQueue<>(queueSize(), RefQueueEntry::compare);
@ -206,7 +205,6 @@ public class MergedReftable extends Reftable {
}
ref = t.rc.getRef();
updateIndex = t.rc.getUpdateIndex();
boolean include = includeDeletes || !t.rc.wasDeleted();
add(t);
skipShadowedRefs(ref.getName());
@ -241,11 +239,6 @@ public class MergedReftable extends Reftable {
return ref;
}
@Override
public long getUpdateIndex() {
return updateIndex;
}
@Override
public void close() {
if (head != null) {
@ -285,7 +278,7 @@ public class MergedReftable extends Reftable {
}
long updateIndex() {
return rc.getUpdateIndex();
return rc.getRef().getUpdateIndex();
}
}

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/RefCursor.java

@ -68,13 +68,6 @@ public abstract class RefCursor implements AutoCloseable {
*/
public abstract Ref getRef();
/**
* Get updateIndex that last modified the current reference.
*
* @return updateIndex that last modified the current reference.
*/
public abstract long getUpdateIndex();
/**
* Whether the current reference was deleted.
*

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableCompactor.java

@ -256,7 +256,7 @@ public class ReftableCompactor {
private void mergeRefs(MergedReftable mr) throws IOException {
try (RefCursor rc = mr.allRefs()) {
while (rc.next()) {
writer.writeRef(rc.getRef(), rc.getUpdateIndex());
writer.writeRef(rc.getRef(), rc.getRef().getUpdateIndex());
}
}
}

10
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java

@ -520,11 +520,6 @@ public class ReftableReader extends Reftable {
return ref;
}
@Override
public long getUpdateIndex() {
return ref.getUpdateIndex();
}
@Override
public void close() {
// Do nothing.
@ -690,11 +685,6 @@ public class ReftableReader extends Reftable {
return ref;
}
@Override
public long getUpdateIndex() {
return ref.getUpdateIndex();
}
@Override
public void close() {
// Do nothing.

Loading…
Cancel
Save