System.out.println(hgRepo.getCommitLastMessage());
}
private void buildFileLog() throws Exception {
final long start = System.nanoTime();
HgLogCommand cmd = new HgLogCommand(hgRepo);
cmd.file("a2.txt", true, false);
final int[] count = new int[] { 0 };
class MyHandler implements HgChangesetTreeHandler, Adaptable {
public void treeElement(HgChangesetTreeHandler.TreeElement entry) throws HgRuntimeException {
StringBuilder sb = new StringBuilder();
HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions());
for (HgChangeset cc : entry.children()) {
sb.append(cc.getRevisionIndex());
sb.append(':');
sb.append(cc.getNodeid().shortNotation());
sb.append(", ");
}
final Pair<Nodeid, Nodeid> parents = entry.parentRevisions();
final boolean isJoin = !parents.first().isNull() && !parents.second().isNull();
final boolean isFork = entry.children().size() > 1;
final HgChangeset cset = entry.changeset();
System.out.printf("%d:%s - %s (%s)\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment(), cset.getPhase());
System.out.printf("\tKnown as %s (file rev:%s)\n", entry.file().getPath(), entry.fileRevision().shortNotation());
if (!isJoin && !isFork && !entry.children().isEmpty()) {
HgChangeset p1 = entry.parents().first();
HgChangeset p2 = entry.parents().second();
System.out.printf("\tp1:%d, p2:%d\n", p1 == null ? -1 : p1.getRevisionIndex(), p2 == null ? -1 : p2.getRevisionIndex());
System.out.printf("\t=> %s\n", sb);
}
if (isJoin) {
HgChangeset p1 = entry.parents().first();
HgChangeset p2 = entry.parents().second();
System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevisionIndex(), p1.getNodeid().shortNotation(), p2.getRevisionIndex(), p2.getNodeid().shortNotation());
if (isFork) {
System.out.print(", ");
}
}
if (isFork) {
if (!isJoin) {
System.out.print('\t');
}
System.out.printf("fork => [%s]", sb);
}
if (isJoin || isFork) {
System.out.println();
}
count[0]++;
}
public <T> T getAdapter(Class<T> adapterClass) {
if (adapterClass == HgFileRenameHandlerMixin.class) {
// in fact, new instance is not very nice, however
// getAdapter callers are supposed to understand the risk of new instance
// and cache returned value
// besides, stateless implementation of RenameDumpHandler
// doesn't really care about few instances
return adapterClass.cast(new Log.RenameDumpHandler());
}
return null;
}
};
cmd.execute(new MyHandler());
System.out.println(count[0]);
final long end = System.nanoTime();
System.out.printf("buildFileLog: %,d ms\n", (end-start)/1000);
}