Mercurial > hg4j
changeset 511:122e0600799f
Respect multiple joins/forks in a history of a single file
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 14 Dec 2012 15:39:49 +0100 |
parents | 90093ee56c0d |
children | 10ca3ede8367 |
files | cmdline/org/tmatesoft/hg/console/Main.java src/org/tmatesoft/hg/core/HgLogCommand.java |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java Thu Dec 13 15:46:40 2012 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Main.java Fri Dec 14 15:39:49 2012 +0100 @@ -172,7 +172,8 @@ private void buildFileLog() throws Exception { final long start = System.nanoTime(); HgLogCommand cmd = new HgLogCommand(hgRepo); - cmd.file("cmdline/org/tmatesoft/hg/console/Remote.java", true); + cmd.file("file1b.txt", true); + final int[] count = new int[] { 0 }; cmd.execute(new HgChangesetTreeHandler() { public void treeElement(HgChangesetTreeHandler.TreeElement entry) { StringBuilder sb = new StringBuilder(); @@ -208,8 +209,10 @@ if (isJoin || isFork) { System.out.println(); } + count[0]++; } }); + System.out.println(count[0]); final long end = System.nanoTime(); System.out.printf("buildFileLog: %,d ms\n", (end-start)/1000); }
--- a/src/org/tmatesoft/hg/core/HgLogCommand.java Thu Dec 13 15:46:40 2012 +0100 +++ b/src/org/tmatesoft/hg/core/HgLogCommand.java Fri Dec 14 15:39:49 2012 +0100 @@ -24,6 +24,7 @@ import java.util.Calendar; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.LinkedList; @@ -541,6 +542,11 @@ queue.add(completeHistory[lastRevisionIndex]); do { HistoryNode withFileChange = queue.removeFirst(); + if (strippedHistoryList.contains(withFileChange)) { + // fork point for the change that was later merged (and we traced + // both lines of development by now. + continue; + } if (withFileChange.children != null) { withFileChange.children.retainAll(strippedHistoryList); } @@ -552,6 +558,12 @@ queue.addLast(withFileChange.parent2); } } while (!queue.isEmpty()); + Collections.sort(strippedHistoryList, new Comparator<HistoryNode>() { + + public int compare(HistoryNode o1, HistoryNode o2) { + return o1.changeset - o2.changeset; + } + }); completeHistory = null; commitRevisions = null; // collected values are no longer valid - shall @@ -666,6 +678,10 @@ child.parent1 = this; addChild(child); } + + public String toString() { + return String.format("<cset:%d, parents: %s, %s>", changeset, parent1 == null ? "-" : String.valueOf(parent1.changeset), parent2 == null ? "-" : String.valueOf(parent2.changeset)); + } } private class ElementImpl implements HgChangesetTreeHandler.TreeElement, HgChangelog.Inspector {