SVNRevision[] revRange = getStartEndRevisions();
SVNRevision startRevision = revRange[0];
SVNRevision endRevision = revRange[1];
boolean force = getCommandLine().hasArgument(SVNArgument.FORCE);
ISVNAnnotateHandler handler = this;
SVNXMLSerializer serializer = null;
if (getCommandLine().hasArgument(SVNArgument.XML)) {
serializer = new SVNXMLSerializer(System.out);
handler = new SVNXMLAnnotateHandler(serializer);
if (!getCommandLine().hasArgument(SVNArgument.INCREMENTAL)) {
((AbstractXMLHandler) handler).startDocument();
}
}
for(int i = 0; i < getCommandLine().getURLCount(); i++) {
String url = getCommandLine().getURL(i);
SVNRevision pegRevision = getCommandLine().getPegRevision(i);
if (serializer != null) {
((SVNXMLAnnotateHandler) handler).startTarget(url);
}
SVNRevision endRev = endRevision;
if ((endRevision == null || !endRevision.isValid()) && (pegRevision == null || !pegRevision.isValid())) {
endRev = SVNRevision.HEAD;
}
try {
logClient.doAnnotate(SVNURL.parseURIEncoded(url), pegRevision, startRevision, endRev, force, handler, null);
} catch (SVNException e) {
if (e.getMessage() != null && e.getMessage().indexOf("binary") >= 0) {
out.println("Skipping binary file: '" + url + "'");
} else {
throw e;
}
}
if (serializer != null) {
((SVNXMLAnnotateHandler) handler).endTarget();
}
}
endRevision = parseRevision(getCommandLine());
for(int i = 0; i < getCommandLine().getPathCount(); i++) {
File path = new File(getCommandLine().getPathAt(i)).getAbsoluteFile();
SVNRevision pegRevision = getCommandLine().getPathPegRevision(i);
if (serializer != null) {
((SVNXMLAnnotateHandler) handler).startTarget(getCommandLine().getPathAt(i));
}
SVNRevision endRev = endRevision;
if ((endRevision == null || !endRevision.isValid()) && (pegRevision == null || !pegRevision.isValid())) {
endRev = SVNRevision.BASE;
}
try {
logClient.doAnnotate(path, pegRevision, startRevision, endRev, force, handler);
} catch (SVNException e) {
if (e.getMessage() != null && e.getMessage().indexOf("binary") >= 0) {
err.println("Skipping binary file: '" + SVNFormatUtil.formatPath(path) + "'");
} else {
throw e;
}
}
if (serializer != null) {
((SVNXMLAnnotateHandler) handler).endTarget();
}
}
if (getCommandLine().hasArgument(SVNArgument.XML)) {
if (!getCommandLine().hasArgument(SVNArgument.INCREMENTAL)) {
((AbstractXMLHandler) handler).endDocument();
}
try {
serializer.flush();
} catch (IOException e) {
}
}
}