* @throws CancelledException if execution of the command was cancelled
* @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
*/
public void executeAnnotate(HgBlameInspector insp) throws HgCallbackTargetException, CancelledException, HgException {
checkFile();
ProgressSupport progress = null;
try {
if (!df.exists()) {
return;
}
final CancelSupport cancel = getCancelSupport(insp, true);
BlameHelper bh = new BlameHelper(insp);
final int startRevIndex = clogRevIndexStart.get(0);
final int endRevIndex = clogRevIndexEnd.get(TIP);
FileHistory fileHistory = bh.prepare(df, startRevIndex, endRevIndex);
//
cancel.checkCancelled();
int totalWork = 0;
for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) {
totalWork += fhc.revisionCount();
}
progress = getProgressSupport(insp);
progress.start(totalWork + 1);
progress.worked(1); // BlameHelper.prepare
//
int[] fileClogParentRevs = new int[2];
int[] fileParentRevs = new int[2];
for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) {
for (int fri : fhc.fileRevisions(iterateDirection)) {
int clogRevIndex = fhc.changeset(fri);
// the way we built fileHistory ensures we won't walk past [changelogRevIndexStart..changelogRevIndexEnd]
assert clogRevIndex >= startRevIndex;
assert clogRevIndex <= endRevIndex;
fhc.fillFileParents(fri, fileParentRevs);
fhc.fillCsetParents(fri, fileClogParentRevs);
bh.annotateChange(fri, clogRevIndex, fileParentRevs, fileClogParentRevs);
progress.worked(1);
cancel.checkCancelled();
}
}
} catch (HgRuntimeException ex) {
throw new HgLibraryFailureException(ex);
} finally {
if (progress != null) {
progress.done();
}
}
}