public long replicateRepository(SVNRepository src, SVNRepository dst, long fromRevision, long toRevision) throws SVNException {
fromRevision = fromRevision <= 0 ? 1 : fromRevision;
long dstLatestRevision = dst.getLatestRevision();
if (dstLatestRevision != fromRevision - 1) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "The target repository''s latest revision must be ''{0}''", new Long(fromRevision - 1));
SVNErrorManager.error(err, SVNLogType.FSFS);
}
if (!src.getRepositoryRoot(true).equals(src.getLocation())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Source repository location must be at repository root ({0}), not at {1}",
new Object[]{src.getRepositoryRoot(true), src.getLocation()});
SVNErrorManager.error(err, SVNLogType.FSFS);
}
if (!dst.getRepositoryRoot(true).equals(dst.getLocation())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Target repository location must be at repository root ({0}), not at {1}",
new Object[]{dst.getRepositoryRoot(true), dst.getLocation()});
SVNErrorManager.error(err, SVNLogType.FSFS);
}
long latestRev = src.getLatestRevision();
toRevision = toRevision > 0 && toRevision <= latestRev ? toRevision : latestRev;
final SVNLogEntry[] currentRevision = new SVNLogEntry[1];
long count = toRevision - fromRevision + 1;
if (dstLatestRevision == 0) {
SVNProperties zeroRevisionProperties = src.getRevisionProperties(0, null);
updateRevisionProperties(dst, 0, zeroRevisionProperties);
}
for (long i = fromRevision; i <= toRevision; i++) {
SVNProperties revisionProps = src.getRevisionProperties(i, null);
String commitMessage = revisionProps.getStringValue(SVNRevisionProperty.LOG);
currentRevision[0] = null;
checkCancelled();
src.log(new String[]{""}, i, i, true, false, 1, new ISVNLogEntryHandler() {
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
currentRevision[0] = logEntry;
}
});
checkCancelled();
if (currentRevision[0] == null || currentRevision[0].getChangedPaths() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Revision ''{0}'' does not contain information on changed paths; probably access is denied", new Long(i));
SVNErrorManager.error(err, SVNLogType.FSFS);
} else if (currentRevision[0].getDate() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Revision ''{0}'' does not contain commit date; probably access is denied", new Long(i));
SVNErrorManager.error(err, SVNLogType.FSFS);
}
fireReplicatingEvent(currentRevision[0]);
commitMessage = commitMessage == null ? "" : commitMessage;
ISVNEditor commitEditor = SVNCancellableEditor.newInstance(dst.getCommitEditor(commitMessage, null), this, src.getDebugLog());
SVNReplicationEditor bridgeEditor = null;
try {
bridgeEditor = new SVNReplicationEditor(src, commitEditor, currentRevision[0]);
final long previousRev = i - 1;
src.update(i, null, true, new ISVNReporterBaton() {
public void report(ISVNReporter reporter) throws SVNException {
reporter.setPath("", null, previousRev, SVNDepth.INFINITY, false);
reporter.finishReport();
}
}, SVNCancellableEditor.newInstance(bridgeEditor, this, src.getDebugLog()));
} catch (SVNException svne) {
try {
bridgeEditor.abortEdit();
} catch (SVNException e) {
}
throw svne;
} catch (Throwable th) {
try {
bridgeEditor.abortEdit();
} catch (SVNException e) {
}
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, th.getMessage());
SVNErrorManager.error(err, th, SVNLogType.FSFS);
}
SVNCommitInfo commitInfo = bridgeEditor.getCommitInfo();
try {