filterInsp.delegateTo(csetTransform);
repo.getChangelog().range(firstCset, lastCset, filterInsp);
csetTransform.checkFailure();
} else {
assert iterateDirection == HgIterateDirection.NewToOld;
BatchRangeHelper brh = new BatchRangeHelper(firstCset, lastCset, BATCH_SIZE, true);
BatchChangesetInspector batchInspector = new BatchChangesetInspector(Math.min(lastCset-firstCset+1, BATCH_SIZE));
filterInsp.delegateTo(batchInspector);
// XXX this batching code is bit verbose, refactor
while (brh.hasNext()) {
brh.next();
repo.getChangelog().range(brh.start(), brh.end(), filterInsp);
for (BatchChangesetInspector.BatchRecord br : batchInspector.iterate(true)) {
csetTransform.next(br.csetIndex, br.csetRevision, br.cset);
csetTransform.checkFailure();
}
batchInspector.reset();
}
}
} else {
filterInsp.delegateTo(csetTransform);
final HgFileRenameHandlerMixin withCopyHandler = Adaptable.Factory.getAdapter(handler, HgFileRenameHandlerMixin.class, null);
FileRenameQueueBuilder frqBuilder = new FileRenameQueueBuilder();
List<QueueElement> fileRenames = frqBuilder.buildFileRenamesQueue(firstCset, lastCset);
progressHelper.start(fileRenames.size());
for (int nameIndex = 0, fileRenamesSize = fileRenames.size(); nameIndex < fileRenamesSize; nameIndex++) {
QueueElement curRename = fileRenames.get(nameIndex);
HgDataFile fileNode = curRename.file();
if (followAncestry) {
TreeBuildInspector treeBuilder = new TreeBuildInspector(followAncestry);
@SuppressWarnings("unused")
List<HistoryNode> fileAncestry = treeBuilder.go(curRename);
int[] commitRevisions = narrowChangesetRange(treeBuilder.getCommitRevisions(), firstCset, lastCset);
if (iterateDirection == HgIterateDirection.OldToNew) {
repo.getChangelog().range(filterInsp, commitRevisions);
csetTransform.checkFailure();
} else {
assert iterateDirection == HgIterateDirection.NewToOld;
// visit one by one in the opposite direction
for (int i = commitRevisions.length-1; i >= 0; i--) {
int csetWithFileChange = commitRevisions[i];
repo.getChangelog().range(csetWithFileChange, csetWithFileChange, filterInsp);
}
}
} else {
// report complete file history (XXX may narrow range with [startRev, endRev], but need to go from file rev to link rev)
int fileStartRev = curRename.fileFrom();
int fileEndRev = curRename.file().getLastRevision(); //curRename.fileTo();
if (iterateDirection == HgIterateDirection.OldToNew) {
fileNode.history(fileStartRev, fileEndRev, filterInsp);
csetTransform.checkFailure();
} else {
assert iterateDirection == HgIterateDirection.NewToOld;
BatchRangeHelper brh = new BatchRangeHelper(fileStartRev, fileEndRev, BATCH_SIZE, true);
BatchChangesetInspector batchInspector = new BatchChangesetInspector(Math.min(fileEndRev-fileStartRev+1, BATCH_SIZE));
filterInsp.delegateTo(batchInspector);
while (brh.hasNext()) {
brh.next();
fileNode.history(brh.start(), brh.end(), filterInsp);
for (BatchChangesetInspector.BatchRecord br : batchInspector.iterate(true /*iterateDirection == IterateDirection.FromNewToOld*/)) {
csetTransform.next(br.csetIndex, br.csetRevision, br.cset);
csetTransform.checkFailure();
}
batchInspector.reset();