# HG changeset patch # User Artem Tikhomirov # Date 1316260891 -7200 # Node ID a7a3395a519e2f4523774fd6fdb9f841ae736f27 # Parent 88c58edc08575ba365773a42d790dfad170434e6 Walk explicit revisions to avoid troubles with unnatural repositories diff -r 88c58edc0857 -r a7a3395a519e src/org/tmatesoft/hg/repo/HgStatusCollector.java --- a/src/org/tmatesoft/hg/repo/HgStatusCollector.java Sat Sep 17 14:00:48 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgStatusCollector.java Sat Sep 17 14:01:31 2011 +0200 @@ -100,7 +100,20 @@ private void initCacheRange(int minRev, int maxRev) { ensureCacheSize(); - repo.getManifest().walk(minRev, maxRev, new HgManifest.Inspector2() { + // In fact, walk(minRev, maxRev) doesn't imply + // there would be maxRev-minRev+1 revisions visited. For example, + // check cpython repo with 'hg log -r 22418:22420 --debug' and admire + // manifest revisions 66650, 21683, 21684. Thus, innocent walk(22418,22420) results in 40k+ revisions and OOME + // Instead, be explicit of what revisions are of interest + assert minRev <= maxRev; + if (maxRev == 22420) { + System.out.println(); + } + int[] revisionsToCollect = new int[maxRev - minRev + 1]; + for (int x = minRev, i = 0; x <= maxRev; i++, x++) { + revisionsToCollect[i] = x; + } + repo.getManifest().walk(new HgManifest.Inspector2() { private ManifestRevision delegate; private boolean cacheHit; // range may include revisions we already know about, do not re-create them @@ -137,7 +150,7 @@ delegate = null; return true; } - }); + }, revisionsToCollect); } /*package-local*/ static ManifestRevision createEmptyManifestRevision() {