DFS: Allow other RefDatabase implementations
Permit a DfsRepository implementation to use a different RefDatabase than DfsRefDatabase. Change-Id: Ia263285f547bde1943993cc994d0222185021a16
This commit is contained in:
parent
4c574b39b4
commit
f0d634eed7
|
@ -70,6 +70,7 @@
|
||||||
import org.eclipse.jgit.lib.ObjectIdSet;
|
import org.eclipse.jgit.lib.ObjectIdSet;
|
||||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
|
import org.eclipse.jgit.lib.RefDatabase;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.storage.pack.PackConfig;
|
import org.eclipse.jgit.storage.pack.PackConfig;
|
||||||
import org.eclipse.jgit.storage.pack.PackStatistics;
|
import org.eclipse.jgit.storage.pack.PackStatistics;
|
||||||
|
@ -78,9 +79,7 @@
|
||||||
/** Repack and garbage collect a repository. */
|
/** Repack and garbage collect a repository. */
|
||||||
public class DfsGarbageCollector {
|
public class DfsGarbageCollector {
|
||||||
private final DfsRepository repo;
|
private final DfsRepository repo;
|
||||||
|
private final RefDatabase refdb;
|
||||||
private final DfsRefDatabase refdb;
|
|
||||||
|
|
||||||
private final DfsObjDatabase objdb;
|
private final DfsObjDatabase objdb;
|
||||||
|
|
||||||
private final List<DfsPackDescription> newPackDesc;
|
private final List<DfsPackDescription> newPackDesc;
|
||||||
|
@ -195,7 +194,7 @@ public boolean pack(ProgressMonitor pm) throws IOException {
|
||||||
|
|
||||||
ctx = (DfsReader) objdb.newReader();
|
ctx = (DfsReader) objdb.newReader();
|
||||||
try {
|
try {
|
||||||
refdb.clearCache();
|
refdb.refresh();
|
||||||
objdb.clearCache();
|
objdb.clearCache();
|
||||||
|
|
||||||
refsBefore = refdb.getRefs(ALL);
|
refsBefore = refdb.getRefs(ALL);
|
||||||
|
|
|
@ -261,6 +261,11 @@ public void create() {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refresh() {
|
||||||
|
clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
clearCache();
|
clearCache();
|
||||||
|
|
|
@ -79,9 +79,6 @@ protected DfsRepository(DfsRepositoryBuilder builder) {
|
||||||
@Override
|
@Override
|
||||||
public abstract DfsObjDatabase getObjectDatabase();
|
public abstract DfsObjDatabase getObjectDatabase();
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract DfsRefDatabase getRefDatabase();
|
|
||||||
|
|
||||||
/** @return a description of this repository. */
|
/** @return a description of this repository. */
|
||||||
public DfsRepositoryDescription getDescription() {
|
public DfsRepositoryDescription getDescription() {
|
||||||
return description;
|
return description;
|
||||||
|
@ -95,7 +92,10 @@ public DfsRepositoryDescription getDescription() {
|
||||||
* the repository cannot be checked.
|
* the repository cannot be checked.
|
||||||
*/
|
*/
|
||||||
public boolean exists() throws IOException {
|
public boolean exists() throws IOException {
|
||||||
return getRefDatabase().exists();
|
if (getRefDatabase() instanceof DfsRefDatabase) {
|
||||||
|
return ((DfsRefDatabase) getRefDatabase()).exists();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +117,7 @@ public StoredConfig getConfig() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanForRepoChanges() throws IOException {
|
public void scanForRepoChanges() throws IOException {
|
||||||
getRefDatabase().clearCache();
|
getRefDatabase().refresh();
|
||||||
getObjectDatabase().clearCache();
|
getObjectDatabase().clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue