Browse Source

DFS: Allow other RefDatabase implementations

Permit a DfsRepository implementation to use a different RefDatabase
than DfsRefDatabase.

Change-Id: Ia263285f547bde1943993cc994d0222185021a16
tags/v4.2.0.201601211800-r
Shawn Pearce 8 years ago
parent
commit
f0d634eed7

+ 3
- 4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java View File

@@ -70,6 +70,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdSet;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.PackConfig;
import org.eclipse.jgit.storage.pack.PackStatistics;
@@ -78,9 +79,7 @@ import org.eclipse.jgit.util.io.CountingOutputStream;
/** Repack and garbage collect a repository. */
public class DfsGarbageCollector {
private final DfsRepository repo;

private final DfsRefDatabase refdb;

private final RefDatabase refdb;
private final DfsObjDatabase objdb;

private final List<DfsPackDescription> newPackDesc;
@@ -195,7 +194,7 @@ public class DfsGarbageCollector {

ctx = (DfsReader) objdb.newReader();
try {
refdb.clearCache();
refdb.refresh();
objdb.clearCache();

refsBefore = refdb.getRefs(ALL);

+ 5
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java View File

@@ -261,6 +261,11 @@ public abstract class DfsRefDatabase extends RefDatabase {
// Nothing to do.
}

@Override
public void refresh() {
clearCache();
}

@Override
public void close() {
clearCache();

+ 5
- 5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java View File

@@ -79,9 +79,6 @@ public abstract class DfsRepository extends Repository {
@Override
public abstract DfsObjDatabase getObjectDatabase();

@Override
public abstract DfsRefDatabase getRefDatabase();

/** @return a description of this repository. */
public DfsRepositoryDescription getDescription() {
return description;
@@ -95,7 +92,10 @@ public abstract class DfsRepository extends Repository {
* the repository cannot be checked.
*/
public boolean exists() throws IOException {
return getRefDatabase().exists();
if (getRefDatabase() instanceof DfsRefDatabase) {
return ((DfsRefDatabase) getRefDatabase()).exists();
}
return true;
}

@Override
@@ -117,7 +117,7 @@ public abstract class DfsRepository extends Repository {

@Override
public void scanForRepoChanges() throws IOException {
getRefDatabase().clearCache();
getRefDatabase().refresh();
getObjectDatabase().clearCache();
}


Loading…
Cancel
Save