}
long rangeStartRev = getRevisionNumber(rangeStart, youngestRevision, repository, source);
long rangeEndRev = getRevisionNumber(rangeEnd, youngestRevision, repository, source);
if (rangeStartRev != rangeEndRev) {
SVNMergeRange range = new SVNMergeRange(rangeStartRev, rangeEndRev, true);
mergeRanges.add(range);
}
}
SVNMergeRangeList mergeRangesList = SVNMergeRangeList.fromCollection(mergeRanges);
mergeRanges = mergeRangesList.getRangesAsList();
if (mergeRanges.isEmpty()) {
return mergeRanges;
}
long oldestRequestedRev = SVNRepository.INVALID_REVISION;
long youngestRequestedRev = SVNRepository.INVALID_REVISION;
for (Iterator rangesIter = mergeRanges.iterator(); rangesIter.hasNext();) {
SVNMergeRange range = (SVNMergeRange) rangesIter.next();
long minRev = Math.min(range.getStartRevision(), range.getEndRevision());
long maxRev = Math.max(range.getStartRevision(), range.getEndRevision());
if (!SVNRevision.isValidRevisionNumber(oldestRequestedRev) || minRev < oldestRequestedRev) {
oldestRequestedRev = minRev;
}
if (!SVNRevision.isValidRevisionNumber(youngestRequestedRev) || maxRev > youngestRequestedRev) {
youngestRequestedRev = maxRev;
}
}
if (pegRevNum < youngestRequestedRev) {
getLocations(sourceURL, null, repository, SVNRevision.create(pegRevNum),
SVNRevision.create(youngestRequestedRev), SVNRevision.UNDEFINED);
pegRevNum = youngestRequestedRev;
}
LinkedList segments = (LinkedList) repository.getLocationSegments("", pegRevNum, youngestRequestedRev,
oldestRequestedRev);
long trimRevision = SVNRepository.INVALID_REVISION;
if (!segments.isEmpty()) {
SVNLocationSegment segment = (SVNLocationSegment) segments.get(0);
if (segment.getStartRevision() != oldestRequestedRev) {
trimRevision = segment.getStartRevision();
} else if (segment.getPath() == null) {
if (segments.size() > 1) {
SVNLocationSegment segment2 = (SVNLocationSegment) segments.get(1);
SVNURL segmentURL = sourceRootURL.appendPath(segment2.getPath(), false);
SVNLocationEntry copyFromLocation = getCopySource(null, segmentURL,
SVNRevision.create(segment2.getStartRevision()));
String copyFromPath = copyFromLocation.getPath();
long copyFromRevision = copyFromLocation.getRevision();
if (copyFromPath != null && SVNRevision.isValidRevisionNumber(copyFromRevision)) {
SVNLocationSegment newSegment = new SVNLocationSegment(copyFromRevision,
copyFromRevision, copyFromPath);
segment.setStartRevision(copyFromRevision + 1);
segments.addFirst(newSegment);
}
}
}
}
SVNLocationSegment[] segmentsArray = (SVNLocationSegment[]) segments.toArray(new SVNLocationSegment[segments.size()]);
List resultMergeSources = new LinkedList();
for (Iterator rangesIter = mergeRanges.iterator(); rangesIter.hasNext();) {
SVNMergeRange range = (SVNMergeRange) rangesIter.next();
if (SVNRevision.isValidRevisionNumber(trimRevision)) {
if (Math.max(range.getStartRevision(), range.getEndRevision()) < trimRevision) {
continue;
}
if (range.getStartRevision() < trimRevision) {
range.setStartRevision(trimRevision);
}
if (range.getEndRevision() < trimRevision) {
range.setEndRevision(trimRevision);
}
}
List mergeSources = combineRangeWithSegments(range, segmentsArray, sourceRootURL);
resultMergeSources.addAll(mergeSources);
}