# HG changeset patch # User Artem Tikhomirov # Date 1308828743 -7200 # Node ID 29231022fec81e7c6f9d3149d93348b7d9c27fe0 # Parent df9d2854d3d65f9db28600cb226eb32a6b19ddd3 Do not expect file history to be ordered diff -r df9d2854d3d6 -r 29231022fec8 src/org/tmatesoft/hg/repo/HgDataFile.java --- a/src/org/tmatesoft/hg/repo/HgDataFile.java Thu Jun 16 04:23:51 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgDataFile.java Thu Jun 23 13:32:23 2011 +0200 @@ -26,6 +26,7 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.TreeMap; @@ -232,12 +233,20 @@ }; content.iterate(start, end, false, insp); final HgChangelog changelog = getRepo().getChangelog(); -// changelog.range(inspector, commitRevisions); not effective when changes are sparse and far from each other + /* + * changelog.range(inspector, commitRevisions); + * Not effective when changes are sparse and far from each other. + * However, it's only single file read, unlike code below (few reads of sequential blocks) + * Need to weight tradeoffs of file read and iteration of sparse files. + */ + // final int HistoricallyCloseCommits = 50; // XXX perhaps, shall increase/decrease based on changelog.revisionCount() // (huge changelog => memory mapped files, each file re-read is more expensive than iterating over records in one read? // // try short sequences on neighboring revisions. + Arrays.sort(commitRevisions); // automatic tools (svnmerge?) produce unnatural file history + // (e.g. cpython/Lib/doctest.py, revision 164 points to 63509, 165 - to 38453) for (int i = 0; i < commitRevisions.length; ) { int x = i; i++;