comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 240:29231022fec8

Do not expect file history to be ordered
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 23 Jun 2011 13:32:23 +0200
parents 6e1373b54e9b
children ad6a046943be
comparison
equal deleted inserted replaced
239:df9d2854d3d6 240:29231022fec8
24 import java.io.FileInputStream; 24 import java.io.FileInputStream;
25 import java.io.IOException; 25 import java.io.IOException;
26 import java.nio.ByteBuffer; 26 import java.nio.ByteBuffer;
27 import java.nio.channels.FileChannel; 27 import java.nio.channels.FileChannel;
28 import java.util.ArrayList; 28 import java.util.ArrayList;
29 import java.util.Arrays;
29 import java.util.Collection; 30 import java.util.Collection;
30 import java.util.TreeMap; 31 import java.util.TreeMap;
31 32
32 import org.tmatesoft.hg.core.HgDataStreamException; 33 import org.tmatesoft.hg.core.HgDataStreamException;
33 import org.tmatesoft.hg.core.HgException; 34 import org.tmatesoft.hg.core.HgException;
230 commitRevisions[count++] = linkRevision; 231 commitRevisions[count++] = linkRevision;
231 } 232 }
232 }; 233 };
233 content.iterate(start, end, false, insp); 234 content.iterate(start, end, false, insp);
234 final HgChangelog changelog = getRepo().getChangelog(); 235 final HgChangelog changelog = getRepo().getChangelog();
235 // changelog.range(inspector, commitRevisions); not effective when changes are sparse and far from each other 236 /*
237 * changelog.range(inspector, commitRevisions);
238 * Not effective when changes are sparse and far from each other.
239 * However, it's only single file read, unlike code below (few reads of sequential blocks)
240 * Need to weight tradeoffs of file read and iteration of sparse files.
241 */
242
236 // 243 //
237 final int HistoricallyCloseCommits = 50; // XXX perhaps, shall increase/decrease based on changelog.revisionCount() 244 final int HistoricallyCloseCommits = 50; // XXX perhaps, shall increase/decrease based on changelog.revisionCount()
238 // (huge changelog => memory mapped files, each file re-read is more expensive than iterating over records in one read? 245 // (huge changelog => memory mapped files, each file re-read is more expensive than iterating over records in one read?
239 // 246 //
240 // try short sequences on neighboring revisions. 247 // try short sequences on neighboring revisions.
248 Arrays.sort(commitRevisions); // automatic tools (svnmerge?) produce unnatural file history
249 // (e.g. cpython/Lib/doctest.py, revision 164 points to 63509, 165 - to 38453)
241 for (int i = 0; i < commitRevisions.length; ) { 250 for (int i = 0; i < commitRevisions.length; ) {
242 int x = i; 251 int x = i;
243 i++; 252 i++;
244 boolean sequential = true; 253 boolean sequential = true;
245 while (i < commitRevisions.length) { 254 while (i < commitRevisions.length) {