}
protected long getRevisionNumber(SVNRevision revision, long[] latestRevisionNumber, SVNRepository repository,
File path) throws SVNException {
if (repository == null && (revision == SVNRevision.HEAD || revision.getDate() != null)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_RA_ACCESS_REQUIRED);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (revision.getNumber() >= 0) {
return revision.getNumber();
} else if (revision.getDate() != null) {
return repository.getDatedRevision(revision.getDate());
} else if (revision == SVNRevision.HEAD) {
if (latestRevisionNumber != null && latestRevisionNumber.length > 0 && SVNRevision.isValidRevisionNumber(latestRevisionNumber[0])) {
return latestRevisionNumber[0];
}
long latestRevision = repository.getLatestRevision();
if (latestRevisionNumber != null && latestRevisionNumber.length > 0) {
latestRevisionNumber[0] = latestRevision;
}
return latestRevision;
} else if (!revision.isValid()) {
return -1;
} else if (revision == SVNRevision.COMMITTED || revision == SVNRevision.WORKING ||
revision == SVNRevision.BASE || revision == SVNRevision.PREVIOUS) {
if (path == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_VERSIONED_PATH_REQUIRED);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNWCAccess wcAccess = createWCAccess();
wcAccess.probeOpen(path, false, 0);
SVNEntry entry = null;
try {
entry = wcAccess.getVersionedEntry(path, false);
} finally {
wcAccess.close();
}
if (revision == SVNRevision.WORKING || revision == SVNRevision.BASE) {
return entry.getRevision();
}
if (entry.getCommittedRevision() < 0) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION, "Path ''{0}'' has no committed revision", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
return revision == SVNRevision.PREVIOUS ? entry.getCommittedRevision() - 1 : entry.getCommittedRevision();
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION, "Unrecognized revision type requested for ''{0}''", path != null ? path : (Object) repository.getLocation());
SVNErrorManager.error(err, SVNLogType.WC);
}
return -1;
}