protected int getFileRevisionsImpl(String path, long startRevision, long endRevision, boolean includeMergedRevisions,
ISVNFileRevisionHandler handler) throws SVNException {
Long srev = getRevisionObject(startRevision);
Long erev = getRevisionObject(endRevision);
SVNDeltaReader deltaReader = new SVNDeltaReader();
try {
openConnection();
Object[] buffer = new Object[]{"get-file-revs",
getRepositoryPath(path),
srev, erev, Boolean.toString(includeMergedRevisions)};
write("(w(s(n)(n)w))", buffer);
authenticate();
boolean hasRevision = false;
int count = 0;
while (true) {
SVNItem item = readItem(false);
if (item.getKind() == SVNItem.WORD && "done".equals(item.getWord())) {
break;
}
hasRevision = true;
if (item.getKind() != SVNItem.LIST) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Revision entry not a list");
SVNErrorManager.error(err, SVNLogType.NETWORK);
}
List items = SVNReader.parseTuple("srll?s", item.getItems(), null);
String name = null;
SVNFileRevision fileRevision = null;
if (handler != null) {
name = SVNReader.getString(items, 0);
long revision = SVNReader.getLong(items, 1);
SVNProperties properties = SVNReader.getProperties(items, 2, null);
SVNProperties propertiesDelta = SVNReader.getPropertyDiffs(items, 3, null);
boolean isMergedRevision = SVNReader.getBoolean(items, 4);
if (name != null) {
fileRevision = new SVNFileRevision(name, revision,
properties, propertiesDelta,
isMergedRevision);
}
}
SVNItem chunkItem = readItem(false);
if (chunkItem.getKind() != SVNItem.BYTES) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
SVNErrorManager.error(err, SVNLogType.NETWORK);
}
boolean hasDelta = chunkItem.getBytes().length > 0;
if (handler != null && fileRevision != null) {
handler.openRevision(fileRevision);
}
if (hasDelta) {
if (handler != null) {
handler.applyTextDelta(name == null ? path : name, null);
}
while (true) {
byte[] line = chunkItem.getBytes();
if (line == null || line.length == 0) {
break;
}
deltaReader.nextWindow(line, 0, line.length, name == null ? path : name, handler);
chunkItem = readItem(false);
if (chunkItem.getKind() != SVNItem.BYTES) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
SVNErrorManager.error(err, SVNLogType.NETWORK);
}
}
deltaReader.reset(name == null ? path : name, handler);
if (handler != null) {
handler.textDeltaEnd(name == null ? path : name);
}
}