HgRepository hgRepo = cmdLineOpts.findRepository();
if (hgRepo.isInvalid()) {
System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
return;
}
HgTags tags = hgRepo.getTags();
final HgChangelog clog = hgRepo.getChangelog();
final Map<TagInfo, Integer> ti2index = new HashMap<TagInfo, Integer>();
final TreeSet<TagInfo> sorted = new TreeSet<HgTags.TagInfo>(new Comparator<TagInfo>() {
public int compare(TagInfo o1, TagInfo o2) {
// reverse, from newer to older (bigger indexes first);
// never ==, tags from same revision in any order, just next to each other
int x1 = ti2index.get(o1);
int x2 = ti2index.get(o2);
return x1 < x2 ? 1 : -1;
}
});
for (TagInfo ti : tags.getAllTags().values()) {
int x = clog.getRevisionIndex(ti.revision()); // XXX in fact, performance hog. Need batch revisionIndex or another improvement
ti2index.put(ti, x);
sorted.add(ti);
}
for (TagInfo ti : sorted) {