RangeListPath rangeListPath = new RangeListPath();
rangeListPath.myPath = path;
rangeListPath.myRangeList = changes.dup();
SVNMergeRange[] rangesArray = rangeListPath.myRangeList.getRanges();
for (int i = 0; i < rangesArray.length; i++) {
SVNMergeRange range = rangesArray[i];
range.setStartRevision(range.getStartRevision() + 1);
}
rangeListPaths.add(rangeListPath);
}
LinkedList combinedList = new LinkedList();
Comparator rangeListPathsComparator = new Comparator() {
public int compare(Object arg1, Object arg2) {
RangeListPath rangeListPath1 = (RangeListPath) arg1;
RangeListPath rangeListPath2 = (RangeListPath) arg2;
SVNMergeRange[] ranges1 = rangeListPath1.myRangeList.getRanges();
SVNMergeRange[] ranges2 = rangeListPath2.myRangeList.getRanges();
SVNMergeRange range1 = ranges1[0];
SVNMergeRange range2 = ranges2[0];
if (range1.getStartRevision() < range2.getStartRevision()) {
return -1;
}
if (range1.getStartRevision() > range2.getStartRevision()) {
return 1;
}
if (range1.getEndRevision() < range2.getEndRevision()) {
return -1;
}
if (range1.getEndRevision() > range2.getEndRevision()) {
return 1;
}
return 0;
}
};
while (rangeListPaths.size() > 1) {
Collections.sort(rangeListPaths, rangeListPathsComparator);
RangeListPath rangeListPath = (RangeListPath) rangeListPaths.get(0);
RangeListPath firstRLP = rangeListPath;
long youngest = rangeListPath.myRangeList.getRanges()[0].getStartRevision();
long nextYoungest = youngest;
int numRevs = 1;
for (; nextYoungest == youngest; numRevs++) {
if (numRevs == rangeListPaths.size()) {
numRevs++;
break;
}
rangeListPath = (RangeListPath) rangeListPaths.get(numRevs);
nextYoungest = rangeListPath.myRangeList.getRanges()[0].getStartRevision();
}
numRevs--;
long youngestEnd = firstRLP.myRangeList.getRanges()[0].getEndRevision();
long tail = nextYoungest - 1;
if (nextYoungest == youngest || youngestEnd < nextYoungest) {
tail = youngestEnd;
}
PathListRange pathListRange = new PathListRange();
pathListRange.myRange = new SVNMergeRange(youngest, tail, false);
List paths = new LinkedList();
for (int i = 0; i < numRevs; i++) {
RangeListPath rp = (RangeListPath) rangeListPaths.get(i);
paths.add(rp.myPath);
}
pathListRange.myPaths = (String[]) paths.toArray(new String[paths.size()]);
combinedList.add(pathListRange);
for (int i = 0; i < numRevs; i++) {
RangeListPath rp = (RangeListPath) rangeListPaths.get(i);
SVNMergeRange range = rp.myRangeList.getRanges()[0];
range.setStartRevision(tail + 1);
if (range.getStartRevision() > range.getEndRevision()) {
if (rp.myRangeList.getSize() == 1) {
rangeListPaths.remove(0);
i--;
numRevs--;
} else {